Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
287d0eb3ee
|
||
|
|
808924a3c7
|
||
|
|
160fdb58f3
|
||
|
|
30103d20ba
|
||
|
|
a3f27e9c91
|
||
|
|
a6f9abcbd0 | ||
|
|
cc77691f2e | ||
|
|
e606c9d638 | ||
|
|
24b385d3f7 | ||
|
|
e5d9a8663c | ||
|
|
fe2524335e | ||
|
|
487da93a29 | ||
|
|
24a55305b9 | ||
|
|
069fc3ea91 | ||
|
|
eeb9cb123e | ||
|
|
cbcf14f0ab | ||
|
|
2378a82c52 | ||
|
|
ebd8df041e | ||
|
|
50fe1ff659 | ||
|
|
c3de636dd5 | ||
|
|
1094de7f26 | ||
|
|
d2c5221291 | ||
|
|
558d7c49df | ||
|
|
de8b275143 | ||
|
|
628c5a2752 | ||
|
|
b414a72204 | ||
|
|
cf7ec84c9a | ||
|
|
cf989070e0 | ||
|
|
33d95a3a57 | ||
|
|
5b3b3baba1 | ||
|
|
e3a386d1d9 | ||
|
|
f40156c0de | ||
|
|
70e5ae2a74 | ||
|
|
1ff03bf8e4 | ||
|
|
547e71724a | ||
|
|
4568f0ec8e | ||
|
|
ff0cabb042 | ||
|
|
d177e8a68b | ||
|
|
e9fad34804 | ||
|
|
9f9fa112d2 | ||
|
|
b006ff1070 | ||
|
|
133d7e626d | ||
|
|
d7931553c4 | ||
|
|
828b199ed9 | ||
|
|
b69604f6fe | ||
|
|
ec6120a73d | ||
|
|
0275c7d087 | ||
|
|
65275413fb | ||
|
|
516a2ee067 | ||
|
|
72deacccf4 | ||
|
|
5e86fa42b2 | ||
|
|
5efed3950a | ||
|
|
02099e7bb9 | ||
|
|
58ab733fbb | ||
|
|
1dad25b059 | ||
|
|
af062ec67a | ||
|
|
ffe9d15206 | ||
|
|
5db8939cd9 | ||
|
|
3fcc824786 | ||
|
|
4d289ed182 | ||
|
|
3c49585130 | ||
|
|
30d43f0119 |
No files matched your search
@@ -0,0 +1 @@
|
||||
.gitea/CODEOWNERS linguist-detectable=false
|
||||
@@ -0,0 +1,3 @@
|
||||
# Pull requests request review from the eligible staff team(s).
|
||||
# One approval from either an Admin or Developer satisfies branch protection.
|
||||
* @trueog/Admins @trueog/Developers
|
||||
+9
-6
@@ -1,8 +1,11 @@
|
||||
/.gradle/
|
||||
target/
|
||||
out/
|
||||
.idea/
|
||||
*.iml
|
||||
*.class
|
||||
.gradle/
|
||||
build/
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
bin/
|
||||
libs/.project
|
||||
libs/.settings/
|
||||
.classpath
|
||||
.settings/
|
||||
.project
|
||||
@@ -1,9 +0,0 @@
|
||||
[submodule "libs/DiamondBank-OG"]
|
||||
path = libs/DiamondBank-OG
|
||||
url = https://github.com/NotAlexNoyle/DiamondBank-OG
|
||||
[submodule "libs/GxUI"]
|
||||
path = libs/GxUI
|
||||
url = https://github.com/NotAlexNoyle/GxUI
|
||||
[submodule "libs/Utilities-OG"]
|
||||
path = libs/Utilities-OG
|
||||
url = https://github.com/NotAlexNoyle/Utilities-OG
|
||||
@@ -0,0 +1,153 @@
|
||||
# GxUI-OG
|
||||
|
||||
[TrueOG Network](https://true-og.net)'s GUI Library, originally written by @Gxorge.
|
||||
|
||||
See [Template-OG](https://git.trueog.net/trueog/Template-OG) or [KotlinTemplate-OG](https://git.trueog.net/trueog/KotlinTemplate-OG) usage and import examples.
|
||||
|
||||
## Building
|
||||
|
||||
> ./gradlew clean build eclipse --warning-mode all
|
||||
|
||||
## Plugins using GxUI-OG
|
||||
|
||||
[DuelEnhancer-OG](https://git.trueog.net/trueog/DuelEnhancer-OG)
|
||||
[Splegg-OG](https://git.trueog.net/trueog/Splegg-OG)
|
||||
[SudoSigns-OG](https://git.trueog.net/trueog/SudoSigns-OG)
|
||||
[TheHerobrine-OG](https://git.trueog.net/trueog/TheHerobrine-OG/)
|
||||
|
||||
## Core GUI API
|
||||
|
||||
Extend `GUIBase`, add `GUIItem`s in `setupItems()`, and call `open(false)`.
|
||||
|
||||
Java:
|
||||
|
||||
```java
|
||||
public final class ExampleMenu extends GUIBase {
|
||||
public ExampleMenu(JavaPlugin plugin, Player player) {
|
||||
super(plugin, player, "&6Example Menu", 27, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupItems() {
|
||||
GUIItem item = new GUIItem(Material.DIAMOND, 1, "&bReward");
|
||||
item.lore(List.of(UtilitiesOG.trueogExpand("&7Click to claim.")));
|
||||
item.button(new GUIButton() {
|
||||
@Override public boolean leftClick() { getPlayer().sendMessage("Claimed"); return true; }
|
||||
@Override public boolean leftClickShift() { return leftClick(); }
|
||||
@Override public boolean rightClick() { return leftClick(); }
|
||||
@Override public boolean rightClickShift() { return leftClick(); }
|
||||
});
|
||||
|
||||
addItem(13, item);
|
||||
}
|
||||
}
|
||||
|
||||
new ExampleMenu(plugin, player).open(false);
|
||||
```
|
||||
|
||||
Kotlin:
|
||||
|
||||
```kotlin
|
||||
class ExampleMenu(plugin: JavaPlugin, player: Player) : GUIBase(plugin, player, "&6Example Menu", 27, true) {
|
||||
override fun setupItems() {
|
||||
val item = GUIItem(Material.DIAMOND, 1, "&bReward")
|
||||
item.lore(listOf(UtilitiesOG.trueogExpand("&7Click to claim.")))
|
||||
item.button(object : GUIButton {
|
||||
override fun leftClick(): Boolean { player.sendMessage("Claimed"); return true }
|
||||
override fun leftClickShift() = leftClick()
|
||||
override fun rightClick() = leftClick()
|
||||
override fun rightClickShift() = leftClick()
|
||||
})
|
||||
|
||||
addItem(13, item)
|
||||
}
|
||||
}
|
||||
|
||||
ExampleMenu(plugin, player).open(false)
|
||||
```
|
||||
|
||||
Notes:
|
||||
|
||||
* `fillEmpty = true` fills unused slots with gray glass panes.
|
||||
* GUI item clicks are cancelled automatically.
|
||||
* A `GUIButton` method should return `true` when the click was handled.
|
||||
* Non-button items can call `item.playErrorSound(false)` to make clicks silent.
|
||||
|
||||
## Progress menu API
|
||||
|
||||
`ProgressMenu` displays a layered progress inventory. The first layer lists sections. Clicking a section opens a
|
||||
second layer containing one material-backed item per goal. Hovering a goal shows its completion state and, for
|
||||
counter goals, its current and target values. Both layers paginate automatically. Goals themselves are read-only;
|
||||
a section may optionally expose one clickable action button on its detail view.
|
||||
|
||||
Java:
|
||||
|
||||
```java
|
||||
ProgressMenu.builder(plugin, player, "&aHome Quests")
|
||||
.section("Home 2 Quest", ProgressMenu.State.IN_PROGRESS)
|
||||
.progress(Material.DIAMOND, "Total Shards", 450, 900)
|
||||
.progress(Material.CLOCK, "Hours Played", 12, 24)
|
||||
.description("&7Click &aClaim &7when ready.")
|
||||
.action(Material.NETHER_STAR, "&aClaim Quest", List.of("&7Claims this quest."), (menu, clicker) -> {
|
||||
if (!canClaim(clicker)) {
|
||||
menu.showActionError("You must meet all requirements first.");
|
||||
return;
|
||||
}
|
||||
claim(clicker);
|
||||
clicker.closeInventory();
|
||||
})
|
||||
.section("Home 6 Quest", ProgressMenu.State.NOT_STARTED)
|
||||
.goal(Material.RED_CONCRETE, "How Did We Get Here?", false)
|
||||
.open();
|
||||
```
|
||||
|
||||
Required imports:
|
||||
|
||||
```java
|
||||
import java.util.List;
|
||||
import net.trueog.gxui.progress.ProgressMenu;
|
||||
import org.bukkit.Material;
|
||||
```
|
||||
|
||||
Kotlin:
|
||||
|
||||
```kotlin
|
||||
ProgressMenu.builder(plugin, player, "&aHome Quests")
|
||||
.section("Home 2 Quest", ProgressMenu.State.IN_PROGRESS)
|
||||
.progress(Material.DIAMOND, "Total Shards", 450, 900)
|
||||
.progress(Material.CLOCK, "Hours Played", 12, 24)
|
||||
.description("&7Click &aClaim &7when ready.")
|
||||
.action(Material.NETHER_STAR, "&aClaim Quest", listOf("&7Claims this quest.")) { menu, clicker ->
|
||||
if (!canClaim(clicker)) {
|
||||
menu.showActionError("You must meet all requirements first.")
|
||||
} else {
|
||||
claim(clicker)
|
||||
clicker.closeInventory()
|
||||
}
|
||||
}
|
||||
.section("Home 6 Quest", ProgressMenu.State.NOT_STARTED)
|
||||
.goal(Material.RED_CONCRETE, "How Did We Get Here?", false)
|
||||
.openSection(0) // Open straight into "Home 2 Quest"; use open() for the section list.
|
||||
```
|
||||
|
||||
### Actions
|
||||
|
||||
- `action(material, name, lore, handler)` gives the current section one button, rendered at `ProgressMenu.ACTION_SLOT`
|
||||
(slot 52, bottom row) on that section's detail view only. Calling it again for the same section replaces the button.
|
||||
`handler` is either a `BiConsumer<ProgressMenu, Player>` or a `Consumer<Player>`; in Kotlin the lambda's arity picks
|
||||
the overload. Every page change creates a fresh `ProgressMenu`, so use the `menu` argument (not a captured instance)
|
||||
when you need to talk back to the open inventory.
|
||||
- `openSection(index)` opens the builder directly in the detail view of the `index`-th section (0-based, in the order
|
||||
they were added). Out-of-range indexes fall back to the first layer. The Back button still returns to the section
|
||||
list.
|
||||
- `menu.showActionError(message)` swaps the action button for a red "Error" pane carrying `message` for about two
|
||||
seconds, plays an error sound, and ignores clicks on the slot until the button returns. Call it on the main thread
|
||||
while the menu is still open; otherwise it does nothing.
|
||||
|
||||
Section icons are always state wool: red for `NOT_STARTED`, yellow for `IN_PROGRESS`, and lime for `COMPLETE`. Goal
|
||||
icons never change with state; completion is communicated through the display name and hover lore. This keeps each
|
||||
block related to the goal it represents while making the first layer immediately scannable.
|
||||
|
||||
## License
|
||||
|
||||
Public domain.
|
||||
Executable
+4
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Fetch all submodule content.
|
||||
git submodule update --force --recursive --init
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
plugins {
|
||||
|
||||
id 'java' // Tell gradle this is a java project.
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' // Import utility to package libraries into .jar file.
|
||||
id 'eclipse' // Import eclipse plugin for IDE integration.
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.9.23' // Import kotlin jvm plugin for kotlin/java integration.
|
||||
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
// Declare java version.
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
}
|
||||
|
||||
group = "net.trueog.template-og" // Declare bundle identifier.
|
||||
version = "1.0" // Declare plugin version (will be in .jar).
|
||||
|
||||
def apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
task fetchAndBuildDependencies {
|
||||
doLast {
|
||||
if (!project.ext.has('dependenciesFetched')) { // Add a property
|
||||
project.ext.set('dependenciesFetched', true)
|
||||
new File('depends').eachLine { line ->
|
||||
def components = line.split(" ") // Split the line
|
||||
def repoUrl = components[0]
|
||||
def ref = components[1]
|
||||
def localPath = components[2]
|
||||
|
||||
// Build
|
||||
exec {
|
||||
workingDir = projectDir
|
||||
commandLine("./gradlew", "build")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
processResources {
|
||||
|
||||
def props = [
|
||||
version: version,
|
||||
apiVersion: apiVersion,
|
||||
]
|
||||
|
||||
inputs.properties props // Indicates to rerun if version changes.
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
|
||||
expand props
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
|
||||
url "https://repo.purpurmc.org/snapshots"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" // Declare kotlin library to be packaged.
|
||||
implementation project(':libs:Utilities-OG')
|
||||
implementation project(':libs:GxUI')
|
||||
implementation project(':libs:DiamondBank-OG')
|
||||
|
||||
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
||||
exclude 'io.github.miniplaceholders.*' // Exclude the MiniPlaceholders package from being shadowed.
|
||||
|
||||
minimize()
|
||||
|
||||
}
|
||||
|
||||
jar.dependsOn shadowJar
|
||||
|
||||
tasks.jar.configure {
|
||||
|
||||
archiveClassifier = "part"
|
||||
|
||||
}
|
||||
|
||||
tasks.shadowJar.configure {
|
||||
|
||||
archiveClassifier = null
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
duplicatesStrategy = 'include'
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
|
||||
options.compilerArgs += ["-parameters"]
|
||||
options.encoding = 'UTF-8' // Override the system character set with a universal set.
|
||||
options.fork = true // Enable compilation in a separate daemon process.
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
|
||||
/* ------------------------------ Plugins ------------------------------ */
|
||||
plugins {
|
||||
id("java") // Import Java plugin.
|
||||
id("java-library") // Import Java Library plugin.
|
||||
id("com.diffplug.spotless") version "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.
|
||||
id("io.freefair.lombok") version "8.13.1" // Import automated lombok support.
|
||||
}
|
||||
|
||||
extra["kotlinAttribute"] = Attribute.of("kotlin-tag", Boolean::class.javaObjectType)
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
/* --------------------------- JDK / Kotlin ---------------------------- */
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17 // Compile with JDK 17 compatibility.
|
||||
toolchain { // Select Java toolchain.
|
||||
languageVersion.set(JavaLanguageVersion.of(17)) // Use JDK 17.
|
||||
vendor.set(JvmVendorSpec.GRAAL_VM) // Use GraalVM CE.
|
||||
}
|
||||
}
|
||||
|
||||
kotlin { jvmToolchain(17) }
|
||||
|
||||
/* ----------------------------- Metadata ------------------------------ */
|
||||
group = "net.trueog.gxui-og" // Declare bundle identifier.
|
||||
|
||||
version = "2.1.0" // Declare plugin version (will be in .jar).
|
||||
|
||||
val apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
/* ----------------------------- Resources ----------------------------- */
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val props = mapOf("version" to version, "apiVersion" to apiVersion)
|
||||
inputs.properties(props) // Indicates to rerun if version changes.
|
||||
filesMatching("plugin.yml") { expand(props) }
|
||||
from("LICENSE") { into("/") } // Bundle licenses into jarfiles.
|
||||
}
|
||||
|
||||
/* ---------------------------- Repos ---------------------------------- */
|
||||
repositories {
|
||||
mavenCentral() // Import the Maven Central Maven Repository.
|
||||
gradlePluginPortal() // Import the Gradle Plugin Portal Maven Repository.
|
||||
maven { url = uri("https://repo.purpurmc.org/snapshots") } // Import the PurpurMC Maven Repository.
|
||||
maven { url = uri("file://${System.getProperty("user.home")}/.m2/repository") }
|
||||
}
|
||||
|
||||
/* ---------------------- 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()
|
||||
}
|
||||
|
||||
tasks.jar { archiveClassifier.set("part") } // Applies to root jarfile only.
|
||||
|
||||
tasks.build { dependsOn(tasks.spotlessApply, tasks.shadowJar) } // Build depends on spotless and shadow.
|
||||
|
||||
/* --------------------------- Javac opts ------------------------------- */
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.add("-parameters") // Enable reflection for java code.
|
||||
options.isFork = true // Run javac in its own process.
|
||||
options.compilerArgs.add("-Xlint:deprecation") // Trigger deprecation warning messages.
|
||||
options.encoding = "UTF-8" // Use UTF-8 file encoding.
|
||||
}
|
||||
|
||||
/* ----------------------------- Auto Formatting ------------------------ */
|
||||
spotless {
|
||||
java {
|
||||
eclipse().configFile("config/formatter/eclipse-java-formatter.xml") // Eclipse java formatting.
|
||||
leadingTabsToSpaces() // Convert leftover leading tabs to spaces.
|
||||
removeUnusedImports() // Remove imports that aren't being called.
|
||||
}
|
||||
kotlinGradle {
|
||||
ktfmt().kotlinlangStyle().configure { it.setMaxWidth(120) } // JetBrains Kotlin formatting.
|
||||
target("build.gradle.kts", "settings.gradle.kts") // Gradle files to format.
|
||||
}
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.18.1" // Declare checkstyle version to use.
|
||||
configFile = file("config/checkstyle/checkstyle.xml") // Point checkstyle to config file.
|
||||
isIgnoreFailures = true // Don't fail the build if checkstyle does not pass.
|
||||
isShowViolations = true // Show the violations in any IDE with the checkstyle plugin.
|
||||
}
|
||||
|
||||
tasks.named("compileJava") {
|
||||
dependsOn("spotlessApply") // Run spotless before compiling with the JDK.
|
||||
}
|
||||
|
||||
tasks.named("spotlessCheck") {
|
||||
dependsOn("spotlessApply") // Run spotless before checking if spotless ran.
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Checkstyle//DTD Checkstyle Configuration 1.3//EN"
|
||||
"https://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
<property name="severity" value="error"/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<module name="FinalLocalVariable"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="Indentation">
|
||||
<property name="severity" value="ignore"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\borg\.junit\.jupiter\.api\.Assertions\.fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="ignoreCase" value="true"/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="(?<!\w)fail\s*\(\s*"Not yet implemented"\s*\)\s*;"/>
|
||||
<property name="message" value="Remove placeholder fail() and implement the test."/>
|
||||
<property name="severity" value="warning"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,404 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<profiles version="23">
|
||||
<profile kind="CodeFormatterProfile" name="TrueOG Network Formatting" version="23">
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_switch_case_arrow_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_enum_constant" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_permitted_types" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_annotations" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assertion_message_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_package" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_permitted_types_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.javadoc_do_not_separate_block_tags" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case_after_arrow" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_arrow" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_parameter" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_arrows_in_switch_on_columns" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.align_selector_in_method_invocation_on_expression_first_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_switch_case_with_arrow_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_switch_case_with_colon" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="80"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_type" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_local_variable" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_field" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.join_line_comments" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_switch_case_with_arrow" value="20"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_annotations_on_method" value="49"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_assertion_message" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="common_lines"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_permitted_types" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="0"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="false"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="1"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/>
|
||||
<setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/>
|
||||
</profile>
|
||||
</profiles>
|
||||
@@ -1,4 +0,0 @@
|
||||
# Each line: RepoURL Branch/Tag LocalPath
|
||||
https://github.com/NotAlexNoyle/Utilities-OG.git main ./libs/Utilities-OG
|
||||
https://github.com/Gxorge/GxUI.git main ./libs/GxGUI
|
||||
https://github.com/NotAlexNoyle/DiamondBank-OG ./libs/DiamondBank-OG
|
||||
@@ -0,0 +1,151 @@
|
||||
/* This is free and unencumbered software released into the public domain */
|
||||
|
||||
import org.gradle.plugins.ide.eclipse.model.EclipseModel
|
||||
import java.nio.file.Files
|
||||
import javax.xml.parsers.DocumentBuilderFactory
|
||||
import javax.xml.transform.OutputKeys
|
||||
import javax.xml.transform.TransformerFactory
|
||||
import javax.xml.transform.dom.DOMSource
|
||||
import javax.xml.transform.stream.StreamResult
|
||||
|
||||
val kotlinAttribute: Attribute<Boolean> by rootProject.extra
|
||||
|
||||
val kotlinPluginProjects = configurations
|
||||
.getByName("compileClasspath")
|
||||
.allDependencies
|
||||
.filterIsInstance<ProjectDependency>()
|
||||
.filter { it -> it.attributes.getAttribute(kotlinAttribute) != null }
|
||||
.map { it.path }
|
||||
kotlinPluginProjects.forEach { evaluationDependsOn(it) }
|
||||
|
||||
val ideLibs: Configuration by
|
||||
configurations.creating {
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
}
|
||||
|
||||
configure<EclipseModel> {
|
||||
project {
|
||||
name = "GxUI-OG-Plugin"
|
||||
}
|
||||
classpath {
|
||||
plusConfigurations.add(ideLibs)
|
||||
}
|
||||
}
|
||||
|
||||
val ideLibDir = layout.buildDirectory.dir("ide-libs")
|
||||
val hashRegex = Regex("-[0-9a-fA-F]{10}(?=\\.jar$)") // Black magic.
|
||||
|
||||
val copyTasks = mutableListOf<TaskProvider<Copy>>()
|
||||
|
||||
kotlinPluginProjects.forEach { path ->
|
||||
val sub = project(path)
|
||||
val shadowJarProv = sub.tasks.named("shadowJar")
|
||||
val copyTask =
|
||||
tasks.register<Copy>("ideCopy${sub.name.replaceFirstChar(Char::titlecase)}") {
|
||||
dependsOn(shadowJarProv)
|
||||
from(shadowJarProv)
|
||||
into(ideLibDir)
|
||||
rename { it.replace(hashRegex, "") } // Remove git commit hash from jarfile.
|
||||
}
|
||||
copyTasks += copyTask
|
||||
}
|
||||
|
||||
/* Ensure the jars exist before .classpath is generated */
|
||||
tasks.named("eclipseClasspath").configure { dependsOn(copyTasks) }
|
||||
|
||||
/* Supply those jars to the ideLibs configuration (after evaluation) */
|
||||
afterEvaluate { dependencies { add("ideLibs", fileTree(ideLibDir) { include("*.jar") }) } }
|
||||
|
||||
val injectIdeLibs =
|
||||
tasks.register("injectIdeLibs") {
|
||||
dependsOn("eclipse") // run after all eclipse files are generated
|
||||
doLast {
|
||||
val cpFile = file(".classpath")
|
||||
if (!cpFile.exists()) return@doLast
|
||||
|
||||
val jars = fileTree(ideLibDir.get()) { include("*.jar") }.files.sortedBy { it.name }
|
||||
if (jars.isEmpty()) return@doLast
|
||||
|
||||
// Parse DOM
|
||||
val dbf = DocumentBuilderFactory.newInstance()
|
||||
val doc = dbf.newDocumentBuilder().parse(cpFile)
|
||||
val root = doc.documentElement
|
||||
|
||||
// Helper to see if an entry already exists
|
||||
fun exists(path: String): Boolean =
|
||||
root.getElementsByTagName("classpathentry").let { list ->
|
||||
(0 until list.length).any { i ->
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue
|
||||
kind == "lib" && p == path
|
||||
}
|
||||
}
|
||||
|
||||
// Remove any entry that points to ide-libs dir (folder or jars) to avoid dupes
|
||||
val toRemove = mutableListOf<org.w3c.dom.Node>()
|
||||
val list = root.getElementsByTagName("classpathentry")
|
||||
val dirPath = ideLibDir.get().asFile.absolutePath
|
||||
for (i in 0 until list.length) {
|
||||
val n = list.item(i)
|
||||
val kind = n.attributes?.getNamedItem("kind")?.nodeValue
|
||||
val p = n.attributes?.getNamedItem("path")?.nodeValue ?: ""
|
||||
if (kind == "lib" && (p == dirPath || p.startsWith("$dirPath/"))) {
|
||||
toRemove += n
|
||||
}
|
||||
}
|
||||
toRemove.forEach { root.removeChild(it) }
|
||||
|
||||
// Append our jar entries LAST
|
||||
jars.forEach { f ->
|
||||
val abs = f.absolutePath
|
||||
if (!exists(abs)) {
|
||||
val entry = doc.createElement("classpathentry")
|
||||
entry.setAttribute("kind", "lib")
|
||||
entry.setAttribute("path", abs)
|
||||
root.appendChild(entry)
|
||||
}
|
||||
}
|
||||
|
||||
// Write back pretty
|
||||
val tf =
|
||||
TransformerFactory.newInstance().newTransformer().apply {
|
||||
setOutputProperty(OutputKeys.INDENT, "yes")
|
||||
setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "1")
|
||||
setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no")
|
||||
setOutputProperty(OutputKeys.ENCODING, "UTF-8")
|
||||
}
|
||||
Files.newBufferedWriter(cpFile.toPath()).use { w -> tf.transform(DOMSource(doc), StreamResult(w)) }
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named("eclipse").configure { finalizedBy(injectIdeLibs) }
|
||||
|
||||
val eclipseModel = extensions.getByType<EclipseModel>()
|
||||
|
||||
fun Project.addResolvableEclipseConfigs() {
|
||||
val jarAttr =
|
||||
objects.named(org.gradle.api.attributes.LibraryElements::class, org.gradle.api.attributes.LibraryElements.JAR)
|
||||
val apiAttr = objects.named(org.gradle.api.attributes.Usage::class, org.gradle.api.attributes.Usage.JAVA_API)
|
||||
|
||||
val compileOnlyRes =
|
||||
configurations.create("eclipseCompileOnly") {
|
||||
extendsFrom(configurations.getByName("compileOnly"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
val compileOnlyApiRes =
|
||||
configurations.create("eclipseCompileOnlyApi") {
|
||||
extendsFrom(configurations.getByName("compileOnlyApi"))
|
||||
isCanBeResolved = true
|
||||
isCanBeConsumed = false
|
||||
attributes.attribute(org.gradle.api.attributes.Usage.USAGE_ATTRIBUTE, apiAttr)
|
||||
attributes.attribute(org.gradle.api.attributes.LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, jarAttr)
|
||||
}
|
||||
eclipseModel.classpath.plusConfigurations.addAll(listOf(compileOnlyRes, compileOnlyApiRes))
|
||||
}
|
||||
|
||||
addResolvableEclipseConfigs()
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
@@ -55,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -84,7 +86,7 @@ done
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
@@ -112,7 +114,7 @@ case "$( uname )" in #(
|
||||
NONSTOP* ) nonstop=true ;;
|
||||
esac
|
||||
|
||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
CLASSPATH="\\\"\\\""
|
||||
|
||||
|
||||
# Determine the Java command to use to start the JVM.
|
||||
@@ -203,7 +205,7 @@ fi
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
@@ -211,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
|
||||
Vendored
+14
-12
@@ -13,6 +13,8 @@
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
@rem SPDX-License-Identifier: Apache-2.0
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,22 +59,22 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
set CLASSPATH=
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
|
||||
@@ -1,121 +0,0 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
.classpath
|
||||
.project
|
||||
.settings/
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
# IntelliJ
|
||||
out/
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
bin/
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
target/
|
||||
*.xml
|
||||
|
||||
|
||||
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
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
/.gradle/
|
||||
/build/
|
||||
@@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
@@ -1,30 +0,0 @@
|
||||
# DiamondBank-OG
|
||||
|
||||
A free and open source Diamond Economy plugin for Spigot inspired by [The Diamond Bank](https://www.spigotmc.org/resources/the-diamond-bank.72020/).\
|
||||
Maintained for TrueOG.
|
||||
|
||||
## PostgreSQL
|
||||
This plugin uses PostgreSQL which needs to be set up first. The Arch Linux wiki has a [pretty good guide](https://wiki.archlinux.org/title/PostgreSQL#Initial_configuration).\
|
||||
The PostgreSQL URL, user, password and the table that should be used are configurable in the config.
|
||||
|
||||
## User Commands
|
||||
|
||||
/balance or /balance \<player name or player uuid>\
|
||||
/bal or /bal \<player name or player uuid>\
|
||||
/balancetop <page number (optional)> /baltop <page number (optional)>\\
|
||||
/deposit <amount (number or "all")>\
|
||||
/withdraw <amount (number or "all")>\
|
||||
/pay \<player name or player uuid> \<amount (number or "all")>
|
||||
|
||||
## Admin Commands
|
||||
|
||||
/setbankbalance \<player name or player uuid> \<balance>
|
||||
|
||||
## Permissions
|
||||
diamondbank-og.balance\
|
||||
diamondbank-og.balance.others\
|
||||
diamondbank-og.balancetop\
|
||||
diamondbank-og.deposit\
|
||||
diamondbank-og.withdraw\
|
||||
diamondbank-og.pay\
|
||||
diamondbank-og.setbankbalance
|
||||
@@ -1,81 +0,0 @@
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm") version "1.9.23"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("maven-publish")
|
||||
id("eclipse")
|
||||
}
|
||||
|
||||
group = "net.trueog.diamondbank"
|
||||
version = "1.1"
|
||||
|
||||
val apiVersion = "1.19"
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenPublication") {
|
||||
groupId = "net.trueog.diamondbank"
|
||||
artifactId = "DiamondBankOG"
|
||||
version = version
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.named<ProcessResources>("processResources") {
|
||||
val props = mapOf(
|
||||
"version" to version,
|
||||
"apiVersion" to apiVersion,
|
||||
)
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.purpurmc.org/snapshots")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://jitpack.io")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT")
|
||||
implementation("com.github.christianniehaus:Utilities-OG:e9ebc26c1f")
|
||||
implementation("com.github.jasync-sql:jasync-postgresql:2.2.4")
|
||||
|
||||
implementation("io.sentry:sentry:7.3.0")
|
||||
implementation("io.sentry:sentry-kotlin-extensions:7.3.0")
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
||||
}
|
||||
|
||||
tasks.shadowJar {
|
||||
minimize()
|
||||
}
|
||||
|
||||
tasks.shadowJar.configure {
|
||||
archiveClassifier.set("")
|
||||
}
|
||||
|
||||
tasks.jar {
|
||||
dependsOn("shadowJar")
|
||||
}
|
||||
|
||||
tasks.jar.configure {
|
||||
archiveClassifier.set("part")
|
||||
}
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(17)
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
vendor = JvmVendorSpec.GRAAL_VM
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
Vendored
-249
@@ -1,249 +0,0 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# 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/subprojects/plugins/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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || 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=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# 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
-92
@@ -1,92 +0,0 @@
|
||||
@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
|
||||
|
||||
@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.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +0,0 @@
|
||||
jdk:
|
||||
- 17.0.9
|
||||
before_install:
|
||||
- sdk install java 17.0.9-graalce
|
||||
- sdk use java 17.0.9-graalce
|
||||
install:
|
||||
- ./gradlew build publishToMavenLocal
|
||||
@@ -1,5 +0,0 @@
|
||||
plugins {
|
||||
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
|
||||
}
|
||||
|
||||
rootProject.name = "DiamondBank-OG"
|
||||
@@ -1,75 +0,0 @@
|
||||
package net.trueog.diamondbankog
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration
|
||||
import java.io.File
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
object Config {
|
||||
lateinit var prefix: String
|
||||
var sentryEnabled by Delegates.notNull<Boolean>()
|
||||
lateinit var sentryDsn: String
|
||||
lateinit var postgresUrl: String
|
||||
lateinit var postgresUser: String
|
||||
lateinit var postgresPassword: String
|
||||
lateinit var postgresTable: String
|
||||
|
||||
fun load(): Boolean {
|
||||
val file = File(DiamondBankOG.plugin.dataFolder, "config.yml")
|
||||
if (!file.exists()) {
|
||||
DiamondBankOG.plugin.saveDefaultConfig()
|
||||
}
|
||||
val config = YamlConfiguration.loadConfiguration(file)
|
||||
config.save(file)
|
||||
|
||||
try {
|
||||
prefix = config.get("prefix") as String
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"prefix\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
sentryEnabled = config.get("sentryEnabled") as Boolean
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"sentryEnabled\" as a boolean")
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
sentryDsn = config.get("sentryDsn") as String
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"sentryDsn\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
postgresUrl = config.get("postgresUrl") as String
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"postgresUrl\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
postgresUser = config.get("postgresUser") as String
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"postgresUser\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
postgresPassword = config.get("postgresPassword") as String
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"postgresPassword\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
try {
|
||||
postgresTable = config.get("postgresTable") as String
|
||||
} catch (_: Exception) {
|
||||
DiamondBankOG.plugin.logger.severe("Failed to parse config option \"postgresTable\" as a string")
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package net.trueog.diamondbankog
|
||||
|
||||
import io.sentry.Sentry
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.future.future
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver
|
||||
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags
|
||||
import net.trueog.diamondbankog.Helper.PostgresFunction
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
import net.trueog.diamondbankog.commands.*
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.plugin.java.JavaPlugin
|
||||
import java.util.*
|
||||
import java.util.concurrent.CompletableFuture
|
||||
|
||||
class DiamondBankOG : JavaPlugin() {
|
||||
companion object {
|
||||
lateinit var plugin: DiamondBankOG
|
||||
lateinit var postgreSQL: PostgreSQL
|
||||
fun isPostgreSQLInitialised() = ::postgreSQL.isInitialized
|
||||
var mm = MiniMessage.builder()
|
||||
.tags(
|
||||
TagResolver.builder()
|
||||
.resolver(StandardTags.color())
|
||||
.resolver(StandardTags.reset())
|
||||
.build()
|
||||
)
|
||||
.build()
|
||||
val blockInventoryFor = mutableListOf<UUID>()
|
||||
val blockCommandsWithInventoryActionsFor = mutableListOf<UUID>()
|
||||
var sentryEnabled: Boolean = false
|
||||
var economyDisabled: Boolean = false
|
||||
}
|
||||
|
||||
override fun onEnable() {
|
||||
plugin = this
|
||||
|
||||
if (Config.load()) {
|
||||
Bukkit.getPluginManager().disablePlugin(this)
|
||||
return
|
||||
}
|
||||
|
||||
if (Config.sentryEnabled) {
|
||||
try {
|
||||
Sentry.init { options ->
|
||||
options.dsn = Config.sentryDsn
|
||||
}
|
||||
sentryEnabled = true
|
||||
} catch (e: Exception) {
|
||||
sentryEnabled = false
|
||||
this.logger.severe("Could not initialise Sentry. The Sentry(-compatible) DSN in your config might be invalid.")
|
||||
}
|
||||
}
|
||||
|
||||
postgreSQL = PostgreSQL()
|
||||
try {
|
||||
postgreSQL.initDB()
|
||||
} catch (e: Exception) {
|
||||
plugin.logger.info(e.toString())
|
||||
Bukkit.getPluginManager().disablePlugin(this)
|
||||
return
|
||||
}
|
||||
|
||||
this.server.pluginManager.registerEvents(Events(), this)
|
||||
|
||||
this.getCommand("deposit")?.setExecutor(Deposit())
|
||||
this.getCommand("withdraw")?.setExecutor(Withdraw())
|
||||
this.getCommand("setbankbalance")?.setExecutor(SetBankBalance())
|
||||
this.getCommand("setbankbal")?.setExecutor(SetBankBalance())
|
||||
this.getCommand("pay")?.setExecutor(Pay())
|
||||
this.getCommand("balancetop")?.setExecutor(Balancetop())
|
||||
this.getCommand("baltop")?.setExecutor(Balancetop())
|
||||
this.getCommand("balance")?.setExecutor(Balance())
|
||||
this.getCommand("bal")?.setExecutor(Balance())
|
||||
this.getCommand("diamondbankreload")?.setExecutor(DiamondBankReload())
|
||||
}
|
||||
|
||||
override fun onDisable() {
|
||||
if (isPostgreSQLInitialised()) postgreSQL.pool.disconnect().get()
|
||||
}
|
||||
|
||||
// API
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun addToPlayerBankBalance(uuid: UUID, amount: Long): CompletableFuture<Boolean> {
|
||||
return GlobalScope.future { postgreSQL.addToPlayerBalance(uuid, amount, BalanceType.BANK_BALANCE) }
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun subtractFromPlayerBankBalance(uuid: UUID, amount: Long): CompletableFuture<Boolean> {
|
||||
return GlobalScope.future { postgreSQL.subtractFromPlayerBalance(uuid, amount, BalanceType.BANK_BALANCE) }
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun getPlayerBalance(uuid: UUID, type: BalanceType): CompletableFuture<PostgreSQL.PlayerBalance> {
|
||||
return GlobalScope.future { postgreSQL.getPlayerBalance(uuid, type) }
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun withdrawFromPlayer(uuid: UUID, amount: Long): CompletableFuture<Boolean> {
|
||||
val player = Bukkit.getPlayer(uuid) ?: Bukkit.getOfflinePlayer(uuid)
|
||||
if (!player.hasPlayedBefore()) return GlobalScope.future { true }
|
||||
if (!player.isOnline) return GlobalScope.future { true }
|
||||
val playerPlayer = player.player ?: return GlobalScope.future { true }
|
||||
|
||||
return GlobalScope.future { Helper.withdrawFromPlayer(playerPlayer, amount) == null }
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
fun payPlayer(senderUuid: UUID, receiverUuid: UUID, amount: Long): CompletableFuture<Boolean> {
|
||||
val sender = Bukkit.getPlayer(senderUuid) ?: Bukkit.getOfflinePlayer(senderUuid)
|
||||
if (!sender.hasPlayedBefore()) return GlobalScope.future { true }
|
||||
if (!sender.isOnline) return GlobalScope.future { true }
|
||||
val senderPlayer = sender.player ?: return GlobalScope.future { true }
|
||||
|
||||
val receiver = Bukkit.getPlayer(receiverUuid) ?: Bukkit.getOfflinePlayer(receiverUuid)
|
||||
if (!receiver.hasPlayedBefore()) return GlobalScope.future { true }
|
||||
|
||||
return GlobalScope.future {
|
||||
Helper.withdrawFromPlayer(senderPlayer, amount) ?: GlobalScope.future { true }
|
||||
|
||||
val error = postgreSQL.addToPlayerBalance(
|
||||
receiver.uniqueId,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
sender.uniqueId,
|
||||
PostgresFunction.ADD_TO_PLAYER_BALANCE, amount, BalanceType.BANK_BALANCE,
|
||||
null, "pay"
|
||||
)
|
||||
true
|
||||
} else false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
package net.trueog.diamondbankog
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Helper.PostgresFunction
|
||||
import net.trueog.diamondbankog.Helper.countDiamonds
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.Listener
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent
|
||||
import org.bukkit.event.inventory.InventoryType
|
||||
import org.bukkit.event.player.PlayerDropItemEvent
|
||||
import org.bukkit.event.player.PlayerJoinEvent
|
||||
import org.bukkit.scheduler.BukkitRunnable
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
class Events : Listener {
|
||||
@EventHandler
|
||||
fun onPlayerJoin(event: PlayerJoinEvent) {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
event.player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return
|
||||
}
|
||||
|
||||
val worldName = event.player.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") return
|
||||
|
||||
GlobalScope.launch {
|
||||
val inventoryDiamonds = event.player.inventory.countDiamonds()
|
||||
var error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
event.player.uniqueId,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
event.player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE,
|
||||
null,
|
||||
"onPlayerJoin"
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
|
||||
val enderChestDiamonds = event.player.enderChest.countDiamonds()
|
||||
error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
event.player.uniqueId,
|
||||
enderChestDiamonds,
|
||||
BalanceType.ENDER_CHEST_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
event.player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
enderChestDiamonds,
|
||||
BalanceType.ENDER_CHEST_BALANCE,
|
||||
null,
|
||||
"onPlayerJoin"
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onEntityPickupItem(event: EntityPickupItemEvent) {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
return
|
||||
}
|
||||
|
||||
val worldName = event.entity.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") return
|
||||
|
||||
val itemType = event.item.itemStack.type
|
||||
if (itemType != Material.DIAMOND && itemType != Material.DIAMOND_BLOCK && itemType != Material.SHULKER_BOX) return
|
||||
|
||||
if (DiamondBankOG.blockInventoryFor.contains(event.entity.uniqueId)) {
|
||||
event.isCancelled = true
|
||||
return
|
||||
}
|
||||
|
||||
val player = event.entity
|
||||
if (player !is Player) return
|
||||
|
||||
object : BukkitRunnable() {
|
||||
override fun run() {
|
||||
GlobalScope.launch {
|
||||
val inventoryDiamonds = player.inventory.countDiamonds()
|
||||
val error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
player.uniqueId,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE,
|
||||
null,
|
||||
"onEntityPickupItem"
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(DiamondBankOG.plugin, 1)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onPlayerDropItem(event: PlayerDropItemEvent) {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
return
|
||||
}
|
||||
|
||||
val worldName = event.player.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") return
|
||||
|
||||
val itemType = event.itemDrop.itemStack.type
|
||||
if (itemType != Material.DIAMOND && itemType != Material.DIAMOND_BLOCK && itemType != Material.SHULKER_BOX) return
|
||||
|
||||
if (DiamondBankOG.blockInventoryFor.contains(event.player.uniqueId)) {
|
||||
event.isCancelled = true
|
||||
return
|
||||
}
|
||||
|
||||
object : BukkitRunnable() {
|
||||
override fun run() {
|
||||
GlobalScope.launch {
|
||||
val inventoryDiamonds = event.player.inventory.countDiamonds()
|
||||
val error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
event.player.uniqueId,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
event.player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE,
|
||||
null,
|
||||
"onPlayerDropItem"
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(DiamondBankOG.plugin, 1)
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
fun onInventoryClose(event: InventoryCloseEvent) {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
return
|
||||
}
|
||||
|
||||
val worldName = event.player.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") return
|
||||
|
||||
object : BukkitRunnable() {
|
||||
override fun run() {
|
||||
GlobalScope.launch {
|
||||
val inventoryDiamonds = event.player.inventory.countDiamonds()
|
||||
var error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
event.player.uniqueId,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
event.player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
inventoryDiamonds,
|
||||
BalanceType.INVENTORY_BALANCE,
|
||||
null,
|
||||
"onPlayerJoin"
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (event.inventory.type != InventoryType.ENDER_CHEST) return@launch
|
||||
val enderChestDiamonds = event.player.enderChest.countDiamonds()
|
||||
error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
event.player.uniqueId,
|
||||
enderChestDiamonds,
|
||||
BalanceType.ENDER_CHEST_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
event.player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
enderChestDiamonds,
|
||||
BalanceType.ENDER_CHEST_BALANCE,
|
||||
null,
|
||||
"onInventoryClose"
|
||||
)
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskLater(DiamondBankOG.plugin, 1)
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// fun onPlayerCommandPreprocess(event: PlayerCommandPreprocessEvent) {
|
||||
// val args = event.message.split(" ", limit = 3)
|
||||
// handleGive(args)
|
||||
// }
|
||||
//
|
||||
// @EventHandler
|
||||
// fun onServerCommand(event: ServerCommandEvent) {
|
||||
// val args = event.command.split(" ", limit = 3)
|
||||
// handleGive(args)
|
||||
// }
|
||||
//
|
||||
// private fun handleGive(args: List<String>) {
|
||||
// GlobalScope.launch {
|
||||
// if (args[0] != "/give" && args[0] != "/essentials:give" && args[0] != "/minecraft:give") return@launch
|
||||
// if (args.size != 3 && args.size != 4) return@launch
|
||||
// if (args[2] != "diamond" && args[2] != "minecraft:diamond") return@launch
|
||||
//
|
||||
// val player = Bukkit.getOfflinePlayer(args[1])
|
||||
// val playerPlayer = player.player ?: return@launch
|
||||
//
|
||||
// if (player.isOnline) {
|
||||
// val inventoryDiamonds = playerPlayer.inventory.countDiamondsInInventory()
|
||||
// val error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
// player.uniqueId,
|
||||
// inventoryDiamonds,
|
||||
// INVENTORY_BALANCE
|
||||
// )
|
||||
// if (error) {
|
||||
// Helper.handleError(
|
||||
// playerPlayer.uniqueId,
|
||||
// SET_PLAYER_BALANCE,
|
||||
// inventoryDiamonds,
|
||||
// INVENTORY_BALANCE,
|
||||
// null,
|
||||
// "handleGive"
|
||||
// )
|
||||
// return@launch
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
@@ -1,412 +0,0 @@
|
||||
package net.trueog.diamondbankog
|
||||
|
||||
import io.sentry.Sentry
|
||||
import io.sentry.SentryEvent
|
||||
import io.sentry.protocol.Message
|
||||
import io.sentry.protocol.User
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.block.ShulkerBox
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.inventory.InventoryType
|
||||
import org.bukkit.inventory.Inventory
|
||||
import org.bukkit.inventory.ItemStack
|
||||
import org.bukkit.inventory.meta.BlockStateMeta
|
||||
import java.util.*
|
||||
import kotlin.math.ceil
|
||||
|
||||
object Helper {
|
||||
enum class PostgresFunction(val string: String) {
|
||||
SET_PLAYER_BALANCE("setPlayerBalance"),
|
||||
ADD_TO_PLAYER_BALANCE("addToPlayerBalance"),
|
||||
SUBTRACT_FROM_PLAYER_BALANCE("subtractFromPlayerBalance")
|
||||
}
|
||||
|
||||
suspend fun withdrawFromPlayer(player: Player, amount: Long): Long? {
|
||||
val somethingWentWrongMessage =
|
||||
DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong.")
|
||||
|
||||
val playerBalance = DiamondBankOG.postgreSQL.getPlayerBalance(player.uniqueId, BalanceType.ALL)
|
||||
if (playerBalance.bankBalance == null || playerBalance.inventoryBalance == null || playerBalance.enderChestBalance == null) {
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
// Withdraw everything
|
||||
if (amount == -1L) {
|
||||
var error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
player.uniqueId,
|
||||
playerBalance.bankBalance,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE, playerBalance.bankBalance, BalanceType.BANK_BALANCE,
|
||||
playerBalance, "withdrawFromPlayer"
|
||||
)
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
error = player.inventory.withdraw(
|
||||
playerBalance.inventoryBalance,
|
||||
playerBalance
|
||||
)
|
||||
if (error) {
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
error = player.enderChest.withdraw(
|
||||
playerBalance.enderChestBalance,
|
||||
playerBalance
|
||||
)
|
||||
if (error) {
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
return playerBalance.bankBalance + playerBalance.inventoryBalance + playerBalance.enderChestBalance
|
||||
}
|
||||
|
||||
if (amount > playerBalance.bankBalance + playerBalance.inventoryBalance + playerBalance.enderChestBalance) {
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Cannot withdraw <yellow>$amount <aqua>${if (amount == 1L) "Diamond" else "Diamonds"} <red>because you only have <yellow>${playerBalance.bankBalance + playerBalance.inventoryBalance} <aqua>${if (playerBalance.bankBalance + playerBalance.inventoryBalance == 1L) "Diamond" else "Diamonds"}<red>."))
|
||||
return null
|
||||
}
|
||||
|
||||
if (amount <= playerBalance.bankBalance) {
|
||||
val error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
player.uniqueId,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE, amount, BalanceType.BANK_BALANCE,
|
||||
playerBalance, "withdrawFromPlayer"
|
||||
)
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
return amount
|
||||
}
|
||||
|
||||
if (amount <= playerBalance.bankBalance + playerBalance.inventoryBalance) {
|
||||
var error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
player.uniqueId,
|
||||
playerBalance.bankBalance,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE, playerBalance.bankBalance, BalanceType.BANK_BALANCE,
|
||||
playerBalance, "withdrawFromPlayer"
|
||||
)
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
error = player.inventory.withdraw(
|
||||
amount - playerBalance.bankBalance,
|
||||
playerBalance
|
||||
)
|
||||
if (error) {
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
return amount
|
||||
}
|
||||
|
||||
var error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
player.uniqueId,
|
||||
playerBalance.bankBalance,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE, playerBalance.bankBalance, BalanceType.BANK_BALANCE,
|
||||
playerBalance, "withdrawFromPlayer"
|
||||
)
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
error = player.inventory.withdraw(playerBalance.inventoryBalance, playerBalance)
|
||||
if (error) {
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
error = player.enderChest.withdraw(
|
||||
amount - (playerBalance.bankBalance + playerBalance.inventoryBalance),
|
||||
playerBalance
|
||||
)
|
||||
if (error) {
|
||||
player.sendMessage(somethingWentWrongMessage)
|
||||
return null
|
||||
}
|
||||
|
||||
return amount
|
||||
}
|
||||
|
||||
private suspend fun Inventory.withdrawDiamondBlocks(
|
||||
player: Player,
|
||||
toBeRemoved: Int,
|
||||
balanceType: BalanceType,
|
||||
isShulkerBox: Boolean
|
||||
): Int? {
|
||||
val diamondBlocks =
|
||||
this.contents.filterNotNull().filter { it.type == Material.DIAMOND_BLOCK }.sumOf { it.amount }
|
||||
if (diamondBlocks == 0) return 0
|
||||
|
||||
val blocksNeeded = ceil(toBeRemoved.toDouble() / 9).toInt()
|
||||
val wholeBlocks = if (blocksNeeded > diamondBlocks) diamondBlocks else blocksNeeded
|
||||
val remainder = (toBeRemoved) % 9
|
||||
val change = if (remainder == 0) 0 else 9 - remainder
|
||||
|
||||
this.removeItem(ItemStack(Material.DIAMOND_BLOCK, wholeBlocks))
|
||||
|
||||
val emptySlots = this.storageContents.filter { it == null }.size * 64
|
||||
val leftOverSpace = this.storageContents.filterNotNull().filter { it.type == Material.DIAMOND }
|
||||
.sumOf { 64 - it.amount }
|
||||
|
||||
if (change > (emptySlots + leftOverSpace)) {
|
||||
if (isShulkerBox) {
|
||||
val emptySlotsInInventory = player.inventory.storageContents.filter { it == null }.size * 64
|
||||
val leftOverSpaceInInventory =
|
||||
player.inventory.storageContents.filterNotNull().filter { it.type == Material.DIAMOND }
|
||||
.sumOf { 64 - it.amount }
|
||||
|
||||
if (change > (emptySlotsInInventory + leftOverSpaceInInventory)) {
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: You don't have enough inventory space in your shulker box to store <yellow>$change <aqua>${if (change == 1) "Diamond" else "Diamonds"} <reset>of change from converting diamond blocks into <aqua>Diamonds<reset>, so the <aqua>${if (change == 1) "Diamond" else "Diamonds"} <reset>has been deposited into your bank."))
|
||||
val error = DiamondBankOG.postgreSQL.addToPlayerBalance(
|
||||
player.uniqueId,
|
||||
change.toLong(),
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.ADD_TO_PLAYER_BALANCE,
|
||||
change.toLong(),
|
||||
balanceType,
|
||||
null,
|
||||
"Inventory.withdrawDiamondBlocks"
|
||||
)
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong."))
|
||||
DiamondBankOG.blockInventoryFor.remove(player.uniqueId)
|
||||
return null
|
||||
}
|
||||
} else {
|
||||
player.inventory.addItem(ItemStack(Material.DIAMOND, change))
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: You don't have enough inventory space in your shulker box to store <yellow>$change <aqua>${if (change == 1) "Diamond" else "Diamonds"} <reset>of change from converting diamond blocks into <aqua>Diamonds<reset>, so the <aqua>${if (change == 1) "Diamond" else "Diamonds"} <reset>have been added to your inventory."))
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: You don't have enough inventory space to store <yellow>$change <aqua>${if (change == 1) "Diamond" else "Diamonds"} <reset>of change from converting diamond blocks into <aqua>Diamonds<reset>, so the <aqua>${if (change == 1) "Diamond" else "Diamonds"} <reset>has been deposited into your bank."))
|
||||
val error = DiamondBankOG.postgreSQL.addToPlayerBalance(
|
||||
player.uniqueId,
|
||||
change.toLong(),
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.ADD_TO_PLAYER_BALANCE,
|
||||
change.toLong(),
|
||||
balanceType,
|
||||
null,
|
||||
"Inventory.withdrawDiamondBlocks"
|
||||
)
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong."))
|
||||
DiamondBankOG.blockInventoryFor.remove(player.uniqueId)
|
||||
return null
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.addItem(ItemStack(Material.DIAMOND, change))
|
||||
}
|
||||
|
||||
return if (blocksNeeded > diamondBlocks) diamondBlocks else (wholeBlocks * 9) - change
|
||||
}
|
||||
|
||||
suspend fun Inventory.withdraw(
|
||||
amount: Long,
|
||||
playerBalance: PostgreSQL.PlayerBalance
|
||||
): Boolean {
|
||||
if (this.holder !is Player) return true
|
||||
|
||||
val player = this.holder as Player
|
||||
DiamondBankOG.blockInventoryFor.add(player.uniqueId)
|
||||
|
||||
val balance = if (this.type == InventoryType.PLAYER) {
|
||||
playerBalance.inventoryBalance!!
|
||||
} else {
|
||||
playerBalance.enderChestBalance!!
|
||||
}
|
||||
|
||||
val balanceType = if (this.type == InventoryType.PLAYER) {
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
} else {
|
||||
BalanceType.ENDER_CHEST_BALANCE
|
||||
}
|
||||
|
||||
val inventoryDiamonds = this.countDiamonds()
|
||||
if (playerBalance.inventoryBalance != inventoryDiamonds) {
|
||||
val error = DiamondBankOG.postgreSQL.setPlayerBalance(
|
||||
player.uniqueId,
|
||||
balance - (amount - inventoryDiamonds),
|
||||
balanceType
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SET_PLAYER_BALANCE,
|
||||
amount,
|
||||
balanceType,
|
||||
playerBalance,
|
||||
"Inventory.withdraw"
|
||||
)
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong."))
|
||||
DiamondBankOG.blockInventoryFor.remove(player.uniqueId)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
val error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
player.uniqueId,
|
||||
amount,
|
||||
balanceType
|
||||
)
|
||||
if (error) {
|
||||
handleError(
|
||||
player.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE,
|
||||
amount,
|
||||
balanceType,
|
||||
playerBalance,
|
||||
"Inventory.withdraw"
|
||||
)
|
||||
player.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong."))
|
||||
DiamondBankOG.blockInventoryFor.remove(player.uniqueId)
|
||||
return true
|
||||
}
|
||||
|
||||
val removeMap = this.removeItem(ItemStack(Material.DIAMOND, amount.toInt()))
|
||||
if (removeMap.isNotEmpty()) {
|
||||
var toBeRemoved = removeMap[0]!!.amount
|
||||
|
||||
val removed = this.withdrawDiamondBlocks(player, toBeRemoved, balanceType, false) ?: return true
|
||||
toBeRemoved -= removed
|
||||
|
||||
if (toBeRemoved != 0) {
|
||||
val itemStacks = this.contents.filterNotNull().filter { it.type == Material.SHULKER_BOX }
|
||||
for (itemStack in itemStacks) {
|
||||
val blockStateMeta = (itemStack.itemMeta as BlockStateMeta)
|
||||
itemStack.itemMeta
|
||||
val shulkerBox = blockStateMeta.blockState as ShulkerBox
|
||||
val shulkerRemoveMap = shulkerBox.inventory.removeItem(ItemStack(Material.DIAMOND, toBeRemoved))
|
||||
|
||||
blockStateMeta.blockState = shulkerBox
|
||||
itemStack.itemMeta = blockStateMeta
|
||||
|
||||
toBeRemoved -= if (shulkerRemoveMap.isEmpty()) toBeRemoved else toBeRemoved - shulkerRemoveMap[0]!!.amount
|
||||
if (toBeRemoved == 0) break
|
||||
}
|
||||
|
||||
if (toBeRemoved != 0) {
|
||||
for (itemStack in itemStacks) {
|
||||
val blockStateMeta = (itemStack.itemMeta as BlockStateMeta)
|
||||
itemStack.itemMeta
|
||||
val shulkerBox = blockStateMeta.blockState as ShulkerBox
|
||||
|
||||
val shulkerRemoved =
|
||||
shulkerBox.inventory.withdrawDiamondBlocks(player, toBeRemoved, balanceType, true)
|
||||
?: return true
|
||||
|
||||
blockStateMeta.blockState = shulkerBox
|
||||
itemStack.itemMeta = blockStateMeta
|
||||
|
||||
toBeRemoved -= shulkerRemoved
|
||||
if (toBeRemoved == 0) break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DiamondBankOG.blockInventoryFor.remove(player.uniqueId)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
fun Inventory.countDiamonds(): Long {
|
||||
val inventoryDiamonds = this.all(Material.DIAMOND).values.sumOf { it.amount }.toLong()
|
||||
val shulkerBoxDiamonds = this.all(Material.SHULKER_BOX).values.sumOf { itemStack ->
|
||||
((itemStack.itemMeta as BlockStateMeta).blockState as ShulkerBox).inventory.all(Material.DIAMOND).values.sumOf { it.amount }
|
||||
}.toLong()
|
||||
val inventoryDiamondBlocks = this.all(Material.DIAMOND_BLOCK).values.sumOf { it.amount * 9 }.toLong()
|
||||
val shulkerBoxDiamondBlocks = this.all(Material.SHULKER_BOX).values.sumOf { itemStack ->
|
||||
((itemStack.itemMeta as BlockStateMeta).blockState as ShulkerBox).inventory.all(Material.DIAMOND_BLOCK).values.sumOf { it.amount * 9 }
|
||||
}.toLong()
|
||||
return inventoryDiamonds + shulkerBoxDiamonds + inventoryDiamondBlocks + shulkerBoxDiamondBlocks
|
||||
}
|
||||
|
||||
fun handleError(
|
||||
uuid: UUID,
|
||||
function: PostgresFunction,
|
||||
amount: Long,
|
||||
balanceType: BalanceType,
|
||||
playerBalance: PostgreSQL.PlayerBalance?,
|
||||
inFunction: String
|
||||
) {
|
||||
DiamondBankOG.economyDisabled = true
|
||||
if (DiamondBankOG.sentryEnabled) {
|
||||
val sentryUser = User()
|
||||
sentryUser.id = uuid.toString()
|
||||
|
||||
val sentryEvent = SentryEvent()
|
||||
sentryEvent.user = sentryUser
|
||||
sentryEvent.setExtra("Function", "${function.string}(amount = $amount, type = $balanceType)")
|
||||
if (playerBalance != null) {
|
||||
if (playerBalance.bankBalance != null) sentryEvent.setExtra("Bank Balance", playerBalance.bankBalance)
|
||||
if (playerBalance.inventoryBalance != null) sentryEvent.setExtra(
|
||||
"Inventory Balance",
|
||||
playerBalance.inventoryBalance
|
||||
)
|
||||
if (playerBalance.enderChestBalance != null) sentryEvent.setExtra(
|
||||
"Ender Chest Balance",
|
||||
playerBalance.enderChestBalance
|
||||
)
|
||||
}
|
||||
|
||||
val message = Message()
|
||||
message.message = "${function.string} failed in $inFunction"
|
||||
sentryEvent.message = message
|
||||
|
||||
Sentry.captureEvent(sentryEvent)
|
||||
}
|
||||
DiamondBankOG.plugin.logger.severe(
|
||||
"""
|
||||
${function.string} failed in $inFunction
|
||||
Player UUID: $uuid
|
||||
Function: ${function.string}(amount = $amount, type = $balanceType)
|
||||
${
|
||||
if (playerBalance != null) {
|
||||
if (playerBalance.bankBalance != null) "Bank Balance: ${playerBalance.bankBalance}" else ""
|
||||
} else ""
|
||||
}
|
||||
${
|
||||
if (playerBalance != null) {
|
||||
if (playerBalance.inventoryBalance != null) "Inventory Balance: ${playerBalance.inventoryBalance}" else ""
|
||||
} else ""
|
||||
}
|
||||
${
|
||||
if (playerBalance != null) {
|
||||
if (playerBalance.enderChestBalance != null) "Ender Chest Balance: ${playerBalance.enderChestBalance}" else ""
|
||||
} else ""
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
@file:JvmName("DiamondBankAPI") // Makes the file appear as 'DiamondBankAPI' class in Java.
|
||||
|
||||
package net.trueog.diamondbankog
|
||||
|
||||
import com.github.jasync.sql.db.asSuspending
|
||||
import com.github.jasync.sql.db.general.ArrayRowData
|
||||
import com.github.jasync.sql.db.pool.ConnectionPool
|
||||
import com.github.jasync.sql.db.postgresql.PostgreSQLConnection
|
||||
import com.github.jasync.sql.db.postgresql.PostgreSQLConnectionBuilder
|
||||
import kotlinx.coroutines.future.await
|
||||
import org.bukkit.Bukkit
|
||||
import java.math.BigDecimal
|
||||
import java.sql.SQLException
|
||||
import java.util.*
|
||||
|
||||
public class PostgreSQL {
|
||||
|
||||
lateinit var pool: ConnectionPool<PostgreSQLConnection>
|
||||
|
||||
enum class BalanceType {
|
||||
BANK_BALANCE, INVENTORY_BALANCE, ENDER_CHEST_BALANCE, ALL
|
||||
}
|
||||
|
||||
@Throws(SQLException::class, ClassNotFoundException::class)
|
||||
fun initDB() {
|
||||
try {
|
||||
pool =
|
||||
PostgreSQLConnectionBuilder.createConnectionPool("${Config.postgresUrl}?user=${Config.postgresUser}&password=${Config.postgresPassword}")
|
||||
val createTable =
|
||||
pool.sendPreparedStatement("CREATE TABLE IF NOT EXISTS ${Config.postgresTable}(uuid TEXT, bank_balance decimal, inventory_balance decimal, ender_chest_balance decimal, unique(uuid))")
|
||||
createTable.join()
|
||||
val createIndex =
|
||||
pool.sendPreparedStatement("CREATE INDEX IF NOT EXISTS idx_balance ON ${Config.postgresTable}(bank_balance, inventory_balance, ender_chest_balance)")
|
||||
createIndex.join()
|
||||
} catch (e: Exception) {
|
||||
DiamondBankOG.economyDisabled = true
|
||||
DiamondBankOG.plugin.logger.severe("ECONOMY DISABLED! Something went wrong while trying to initialise PostgreSQL. Is PostgreSQL running? Are the PostgreSQL config variables correct?")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
public suspend fun setPlayerBalance(uuid: UUID, balance: Long, type: BalanceType): Boolean {
|
||||
try {
|
||||
val connection = pool.asSuspending.connect()
|
||||
|
||||
val balanceType = when (type) {
|
||||
BalanceType.BANK_BALANCE -> "bank_balance"
|
||||
BalanceType.INVENTORY_BALANCE -> "inventory_balance"
|
||||
BalanceType.ENDER_CHEST_BALANCE -> "ender_chest_balance"
|
||||
else -> return true
|
||||
}
|
||||
|
||||
val preparedStatement =
|
||||
connection.sendPreparedStatement("INSERT INTO ${Config.postgresTable}(uuid, $balanceType) VALUES('$uuid', $balance) ON CONFLICT (uuid) DO UPDATE SET $balanceType = excluded.$balanceType")
|
||||
preparedStatement.await()
|
||||
} catch (e: Exception) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
public suspend fun addToPlayerBalance(uuid: UUID, amount: Long, type: BalanceType): Boolean {
|
||||
val playerBalance = getPlayerBalanceWrapper(uuid, type) ?: return true
|
||||
|
||||
val error = setPlayerBalance(uuid, playerBalance + amount, type)
|
||||
return error
|
||||
}
|
||||
|
||||
public suspend fun subtractFromPlayerBalance(uuid: UUID, amount: Long, type: BalanceType): Boolean {
|
||||
val playerBalance = getPlayerBalanceWrapper(uuid, type) ?: return true
|
||||
|
||||
val error = setPlayerBalance(uuid, playerBalance - amount, type)
|
||||
return error
|
||||
}
|
||||
|
||||
private suspend fun getPlayerBalanceWrapper(uuid: UUID, type: BalanceType): Long? {
|
||||
val playerBalance = getPlayerBalance(uuid, type)
|
||||
|
||||
return when (type) {
|
||||
BalanceType.BANK_BALANCE -> playerBalance.bankBalance
|
||||
BalanceType.INVENTORY_BALANCE -> playerBalance.inventoryBalance
|
||||
BalanceType.ENDER_CHEST_BALANCE -> playerBalance.enderChestBalance
|
||||
else -> return null
|
||||
}
|
||||
}
|
||||
|
||||
data class PlayerBalance(val bankBalance: Long?, val inventoryBalance: Long?, val enderChestBalance: Long?)
|
||||
|
||||
public suspend fun getPlayerBalance(uuid: UUID, type: BalanceType): PlayerBalance {
|
||||
var bankBalance: Long? = null
|
||||
var inventoryBalance: Long? = null
|
||||
var enderChestBalance: Long? = null
|
||||
try {
|
||||
val connection = pool.asSuspending.connect()
|
||||
|
||||
val balanceType = when (type) {
|
||||
BalanceType.BANK_BALANCE -> "bank_balance"
|
||||
BalanceType.INVENTORY_BALANCE -> "inventory_balance"
|
||||
BalanceType.ENDER_CHEST_BALANCE -> "ender_chest_balance"
|
||||
BalanceType.ALL -> "bank_balance, inventory_balance, ender_chest_balance"
|
||||
}
|
||||
|
||||
val preparedStatement =
|
||||
connection.sendPreparedStatement("SELECT $balanceType FROM ${Config.postgresTable} WHERE uuid = '$uuid' LIMIT 1")
|
||||
val result = preparedStatement.await()
|
||||
|
||||
if (result.rows.size != 0) {
|
||||
val rowData = result.rows[0] as ArrayRowData
|
||||
|
||||
when (type) {
|
||||
BalanceType.BANK_BALANCE -> {
|
||||
bankBalance = if (rowData.columns[0] != null) {
|
||||
(rowData.columns[0] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
}
|
||||
|
||||
BalanceType.INVENTORY_BALANCE -> {
|
||||
inventoryBalance = if (rowData.columns[0] != null) {
|
||||
(rowData.columns[0] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
}
|
||||
|
||||
BalanceType.ENDER_CHEST_BALANCE -> {
|
||||
enderChestBalance = if (rowData.columns[0] != null) {
|
||||
(rowData.columns[0] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
}
|
||||
|
||||
BalanceType.ALL -> {
|
||||
bankBalance = if (rowData.columns[0] != null) {
|
||||
(rowData.columns[0] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
inventoryBalance = if (rowData.columns[1] != null) {
|
||||
(rowData.columns[1] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
enderChestBalance = if (rowData.columns[2] != null) {
|
||||
(rowData.columns[2] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
}
|
||||
}
|
||||
} else {
|
||||
bankBalance = 0L
|
||||
inventoryBalance = 0L
|
||||
enderChestBalance = 0L
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
DiamondBankOG.plugin.logger.info(e.toString())
|
||||
}
|
||||
return PlayerBalance(bankBalance, inventoryBalance, enderChestBalance)
|
||||
}
|
||||
|
||||
public suspend fun getBaltop(offset: Int): MutableMap<String?, Long>? {
|
||||
try {
|
||||
val connection = pool.asSuspending.connect()
|
||||
val preparedStatement =
|
||||
connection.sendPreparedStatement("SELECT * FROM ${Config.postgresTable} ORDER BY bank_balance DESC, inventory_balance DESC, ender_chest_balance DESC OFFSET $offset LIMIT 10")
|
||||
val result = preparedStatement.await()
|
||||
val baltop = mutableMapOf<String?, Long>()
|
||||
result.rows.forEach {
|
||||
val rowData = it as ArrayRowData
|
||||
val bankBalance = if (rowData.columns[1] != null) {
|
||||
(rowData.columns[1] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
val inventoryBalance = if (rowData.columns[2] != null) {
|
||||
(rowData.columns[2] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
val enderChestBalance = if (rowData.columns[3] != null) {
|
||||
(rowData.columns[3] as BigDecimal).toLong()
|
||||
} else 0L
|
||||
|
||||
val player = Bukkit.getPlayer(UUID.fromString(rowData.columns[0] as String)) ?: Bukkit.getOfflinePlayer(
|
||||
UUID.fromString(rowData.columns[0] as String)
|
||||
)
|
||||
baltop[player.name] = bankBalance + inventoryBalance + enderChestBalance
|
||||
}
|
||||
return baltop
|
||||
} catch (e: Exception) {
|
||||
DiamondBankOG.plugin.logger.info(e.toString())
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
suspend fun getNumberOfRows(): Long? {
|
||||
var number: Long? = null
|
||||
try {
|
||||
val connection = pool.asSuspending.connect()
|
||||
val preparedStatement =
|
||||
connection.sendPreparedStatement("SELECT count(*) AS exact_count FROM ${Config.postgresTable}")
|
||||
val result = preparedStatement.await()
|
||||
|
||||
if (result.rows.size != 0) {
|
||||
val rowData = result.rows[0] as ArrayRowData
|
||||
number = if (rowData.columns[0] != null) {
|
||||
rowData.columns[0] as Long
|
||||
} else 0L
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
DiamondBankOG.plugin.logger.info(e.toString())
|
||||
}
|
||||
return number
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
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 java.util.*
|
||||
|
||||
class Balance : CommandExecutor {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
GlobalScope.launch {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("diamondbank-og.balance")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (args == null) return@launch
|
||||
|
||||
if (sender !is Player) {
|
||||
if (args.isEmpty()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Please provide that name or UUID of the player that you want to check the balance of."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val otherPlayer = try {
|
||||
Bukkit.getPlayer(UUID.fromString(args[0])) ?: Bukkit.getOfflinePlayer(UUID.fromString(args[0]))
|
||||
} catch (_: Exception) {
|
||||
Bukkit.getPlayer(args[0]) ?: Bukkit.getOfflinePlayer(args[0])
|
||||
}
|
||||
if (!otherPlayer.hasPlayedBefore()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>That player doesn't exist."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val balance = DiamondBankOG.postgreSQL.getPlayerBalance(
|
||||
otherPlayer.uniqueId,
|
||||
BalanceType.ALL
|
||||
)
|
||||
if (balance.bankBalance == null || balance.inventoryBalance == null || balance.enderChestBalance == null) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to get your balance."))
|
||||
return@launch
|
||||
}
|
||||
val totalBalance = balance.bankBalance + balance.inventoryBalance + balance.enderChestBalance
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("<green>Balance of <red>${otherPlayer.name}<green>: <yellow>$totalBalance <aqua>${if (totalBalance == 1L) "Diamond" else "Diamonds"} <white>(<red>Bank: <yellow>${balance.bankBalance}<white>, <red>Inventory: <yellow>${balance.inventoryBalance}<white>, <red>Ender Chest: <yellow>${balance.enderChestBalance}<white>)."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val balancePlayer = if (args.isEmpty()) {
|
||||
sender
|
||||
} else {
|
||||
if (!sender.hasPermission("diamondbank-og.balance.others")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val otherPlayer = try {
|
||||
Bukkit.getPlayer(UUID.fromString(args[0])) ?: Bukkit.getOfflinePlayer(UUID.fromString(args[0]))
|
||||
} catch (_: Exception) {
|
||||
Bukkit.getPlayer(args[0]) ?: Bukkit.getOfflinePlayer(args[0])
|
||||
}
|
||||
if (!otherPlayer.hasPlayedBefore()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>That player doesn't exist."))
|
||||
return@launch
|
||||
}
|
||||
otherPlayer
|
||||
}
|
||||
val balance = DiamondBankOG.postgreSQL.getPlayerBalance(
|
||||
balancePlayer.uniqueId,
|
||||
BalanceType.ALL
|
||||
)
|
||||
if (balance.bankBalance == null || balance.inventoryBalance == null || balance.enderChestBalance == null) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to get your balance."))
|
||||
return@launch
|
||||
}
|
||||
val totalBalance = balance.bankBalance + balance.inventoryBalance + balance.enderChestBalance
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("<green>Balance${if (balancePlayer.uniqueId != sender.uniqueId) " of <red>${balancePlayer.name}" else ""}<green>: <yellow>$totalBalance <aqua>${if (totalBalance == 1L) "Diamond" else "Diamonds"} <white>(<red>Bank: <yellow>${balance.bankBalance}<white>, <red>Inventory: <yellow>${balance.inventoryBalance}<white>, <red>Ender Chest: <yellow>${balance.enderChestBalance}<white>)."))
|
||||
return@launch
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
import kotlin.math.ceil
|
||||
|
||||
class Balancetop : CommandExecutor {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
GlobalScope.launch {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("diamondbank-og.balancetop")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (args == null) return@launch
|
||||
if (args.size > 1) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Please (only) optionally provide the page number."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
var offset = 0
|
||||
var index = 1
|
||||
if (args.size == 1) {
|
||||
try {
|
||||
index = args[0].toInt()
|
||||
} catch (_: Exception) {
|
||||
sender.sendMessage("Invalid argument")
|
||||
return@launch
|
||||
}
|
||||
offset = 10 * (index - 1)
|
||||
}
|
||||
|
||||
val baltop = DiamondBankOG.postgreSQL.getBaltop(offset)
|
||||
if (baltop == null) {
|
||||
sender.sendMessage("${Config.prefix}<reset>: <red>Something went wrong while trying to get the information for balancetop.")
|
||||
return@launch
|
||||
}
|
||||
val numberOfRows = DiamondBankOG.postgreSQL.getNumberOfRows()
|
||||
if (numberOfRows == null) {
|
||||
sender.sendMessage("${Config.prefix}<reset>: <red>Something went wrong while trying to get the information for balancetop.")
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (index > ceil(numberOfRows / 10.0)) {
|
||||
sender.sendMessage("The amount of pages only goes up to $numberOfRows")
|
||||
return@launch
|
||||
}
|
||||
var baltopMessage =
|
||||
("<yellow>---- <gold>Balancetop <yellow>-- <gold>Page <red>$index<gold>/<red>${ceil(numberOfRows / 10.0).toLong()} <yellow>----<reset>")
|
||||
baltop.forEach {
|
||||
if (it.key == null) {
|
||||
sender.sendMessage("${Config.prefix}<reset>: <red>Something went wrong while trying to get the information for balancetop.")
|
||||
return@launch
|
||||
}
|
||||
baltopMessage += "\n<red>${baltopMessage.lines().size + (10 * (index - 1))}<reset>. ${if (it.key == sender.name) "<red>" else ""}${it.key}<reset>, ${it.value}"
|
||||
}
|
||||
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize(baltopMessage))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,134 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import net.trueog.diamondbankog.Helper
|
||||
import net.trueog.diamondbankog.Helper.PostgresFunction
|
||||
import net.trueog.diamondbankog.Helper.withdraw
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class Deposit : CommandExecutor {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
GlobalScope.launch {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (sender !is Player) {
|
||||
sender.sendMessage("You can only execute this command as a player.")
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (DiamondBankOG.blockCommandsWithInventoryActionsFor.contains(sender.uniqueId)) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You are currently blocked from using /deposit."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val worldName = sender.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You cannot use /deposit <aqua>Diamonds <red>when in a minigame."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("diamondbank-og.deposit")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (args == null || args.isEmpty()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You did not provide the amount of <aqua>dDiamonds <red>that you want to deposit."))
|
||||
return@launch
|
||||
}
|
||||
if (args.size != 1) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Please (only) provide the amount of <aqua>dDiamonds <red>you want to deposit. Either a number or \"all\"."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val playerBalance =
|
||||
DiamondBankOG.postgreSQL.getPlayerBalance(sender.uniqueId, BalanceType.INVENTORY_BALANCE)
|
||||
if (playerBalance.inventoryBalance == null) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to get your balance."))
|
||||
return@launch
|
||||
}
|
||||
if (playerBalance.inventoryBalance == 0L) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You don't have any <aqua>Diamonds <red>to deposit."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
var amount = playerBalance.inventoryBalance
|
||||
if (args[0] != "all") {
|
||||
try {
|
||||
amount = args[0].toLong()
|
||||
if (amount < 0) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You cannot deposit a negative amount."))
|
||||
return@launch
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Invalid argument."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (amount > playerBalance.inventoryBalance) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have <yellow>$amount <aqua>${if (amount == 1L) "Diamond" else "Diamonds"} <red>in your inventory."))
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
|
||||
DiamondBankOG.blockInventoryFor.add(sender.uniqueId)
|
||||
|
||||
var error = sender.inventory.withdraw(amount, playerBalance)
|
||||
if (error) return@launch
|
||||
|
||||
error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
sender.uniqueId,
|
||||
amount,
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
sender.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE,
|
||||
amount,
|
||||
BalanceType.INVENTORY_BALANCE,
|
||||
playerBalance,
|
||||
"deposit"
|
||||
)
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to deposit."))
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
return@launch
|
||||
}
|
||||
|
||||
error = DiamondBankOG.postgreSQL.addToPlayerBalance(
|
||||
sender.uniqueId,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
sender.uniqueId,
|
||||
PostgresFunction.ADD_TO_PLAYER_BALANCE,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE,
|
||||
playerBalance,
|
||||
"deposit"
|
||||
)
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to deposit."))
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
return@launch
|
||||
}
|
||||
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <green>Successfully deposited <yellow>$amount <aqua>${if (amount == 1L) "Diamond" else "Diamonds"} <green>into your bank account."))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import io.sentry.Sentry
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import net.trueog.diamondbankog.PostgreSQL
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
|
||||
class DiamondBankReload : CommandExecutor {
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
if (Config.load()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("<red>Failed to reload the config. Check the console for more information."))
|
||||
Bukkit.getPluginManager().disablePlugin(DiamondBankOG.plugin)
|
||||
return true
|
||||
}
|
||||
|
||||
if (Config.sentryEnabled) {
|
||||
try {
|
||||
Sentry.init { options ->
|
||||
options.dsn = Config.sentryDsn
|
||||
}
|
||||
DiamondBankOG.sentryEnabled = true
|
||||
} catch (e: Exception) {
|
||||
DiamondBankOG.sentryEnabled = false
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Could not initialise Sentry. The Sentry(-compatible) DSN in your config might be invalid."))
|
||||
}
|
||||
}
|
||||
|
||||
DiamondBankOG.postgreSQL = PostgreSQL()
|
||||
try {
|
||||
DiamondBankOG.postgreSQL.initDB()
|
||||
} catch (e: Exception) {
|
||||
DiamondBankOG.plugin.logger.info(e.toString())
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("<red>Failed to reload the config. Check the console for more information."))
|
||||
Bukkit.getPluginManager().disablePlugin(DiamondBankOG.plugin)
|
||||
return true
|
||||
}
|
||||
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <green>Successfully reloaded the config."))
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import net.trueog.diamondbankog.Helper
|
||||
import net.trueog.diamondbankog.Helper.PostgresFunction
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
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 java.util.*
|
||||
|
||||
class Pay : CommandExecutor {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
GlobalScope.launch {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (sender !is Player) {
|
||||
sender.sendMessage("You can only execute this command as a player.")
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (DiamondBankOG.blockCommandsWithInventoryActionsFor.contains(sender.uniqueId)) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You are currently blocked from using /pay."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val worldName = sender.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You cannot use /pay <aqua>Diamonds <red>when in a minigame."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("diamondbank-og.pay")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (args == null || args.isEmpty()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You did not provide the name or the UUID of a player and the amount of <aqua>Diamonds<red>."))
|
||||
return@launch
|
||||
}
|
||||
if (args.size != 2) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Please (only) provide the name or the UUID of a player and the amount of <aqua>Diamonds<red>."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val receiver = try {
|
||||
Bukkit.getPlayer(UUID.fromString(args[0])) ?: Bukkit.getOfflinePlayer(UUID.fromString(args[0]))
|
||||
} catch (_: Exception) {
|
||||
Bukkit.getPlayer(args[0]) ?: Bukkit.getOfflinePlayer(args[0])
|
||||
}
|
||||
|
||||
if (!receiver.hasPlayedBefore()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>That player doesn't exist."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
var amount = -1L
|
||||
if (args[0] != "all") {
|
||||
try {
|
||||
amount = args[1].toLong()
|
||||
if (amount < 0) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You cannot pay a negative amount."))
|
||||
return@launch
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Invalid argument."))
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
|
||||
val withdrawnAmount = Helper.withdrawFromPlayer(sender, amount) ?: return@launch
|
||||
|
||||
val error = DiamondBankOG.postgreSQL.addToPlayerBalance(
|
||||
receiver.uniqueId,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
sender.uniqueId,
|
||||
PostgresFunction.ADD_TO_PLAYER_BALANCE, amount, BalanceType.BANK_BALANCE,
|
||||
null, "pay"
|
||||
)
|
||||
}
|
||||
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <green>Successfully paid <yellow>$withdrawnAmount <aqua>${if (withdrawnAmount == 1L) "Diamond" else "Diamonds"} <green>to <red>${receiver.name}<green>."))
|
||||
|
||||
if (receiver.isOnline) {
|
||||
val receiverPlayer = receiver.player ?: return@launch
|
||||
receiverPlayer.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <green>${sender.name} has paid you <yellow>$withdrawnAmount <aqua>${if (withdrawnAmount == 1L) "Diamond" else "Diamonds"}<green>."))
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
-66
@@ -1,66 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
import java.util.*
|
||||
|
||||
class SetBankBalance : CommandExecutor {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
GlobalScope.launch {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("diamondbank-og.setbankbalance")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (args == null || args.isEmpty()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You did not provide the name or the UUID of a player and the amount of <aqua>Diamonds<red>."))
|
||||
return@launch
|
||||
}
|
||||
if (args.size != 2) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Please (only) provide the name or the UUID of a player and the amount of <aqua>Diamonds<red>."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val player = try {
|
||||
Bukkit.getPlayer(UUID.fromString(args[0])) ?: Bukkit.getOfflinePlayer(UUID.fromString(args[0]))
|
||||
} catch (_: Exception) {
|
||||
Bukkit.getPlayer(args[0]) ?: Bukkit.getOfflinePlayer(args[0])
|
||||
}
|
||||
if (!player.hasPlayedBefore()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>That player doesn't exist."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val balance: Long
|
||||
try {
|
||||
balance = args[1].toLong()
|
||||
} catch (_: Exception) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Invalid argument."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val error =
|
||||
DiamondBankOG.postgreSQL.setPlayerBalance(player.uniqueId, balance, BalanceType.BANK_BALANCE)
|
||||
if (error) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to set that player's balance."))
|
||||
return@launch
|
||||
}
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <green>Successfully set the balance of <red>${player.name} <green>to <yellow>$balance <aqua>${if (balance == 1L) "Diamond" else "Diamonds"}<green>."))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package net.trueog.diamondbankog.commands
|
||||
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import net.trueog.diamondbankog.Config
|
||||
import net.trueog.diamondbankog.DiamondBankOG
|
||||
import net.trueog.diamondbankog.Helper
|
||||
import net.trueog.diamondbankog.Helper.PostgresFunction
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.command.Command
|
||||
import org.bukkit.command.CommandExecutor
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
class Withdraw : CommandExecutor {
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>?): Boolean {
|
||||
GlobalScope.launch {
|
||||
if (DiamondBankOG.economyDisabled) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>The economy is disabled because of a severe error. Please notify a staff member."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (sender !is Player) {
|
||||
sender.sendMessage("You can only execute this command as a player.")
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (DiamondBankOG.blockCommandsWithInventoryActionsFor.contains(sender.uniqueId)) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You are currently blocked from using /withdraw."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
val worldName = sender.world.name
|
||||
if (worldName != "world" && worldName != "world_nether" && worldName != "world_the_end") {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You cannot use /withdraw when in a minigame."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (!sender.hasPermission("diamondbank-og.withdraw")) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You do not have permission to use this command."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (args == null || args.isEmpty()) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You did not provide the amount of <aqua>Diamonds <red>that you want to withdraw."))
|
||||
return@launch
|
||||
}
|
||||
if (args.size != 1) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Please (only) provide the amount of <aqua>Diamonds <red>you want to withdraw. Either a number or \"all\"."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
var amount = -1L
|
||||
if (args[0] != "all") {
|
||||
try {
|
||||
amount = args[0].toLong()
|
||||
if (amount < 0) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You cannot withdraw a negative amount."))
|
||||
return@launch
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Invalid argument."))
|
||||
return@launch
|
||||
}
|
||||
}
|
||||
|
||||
val playerBalance =
|
||||
DiamondBankOG.postgreSQL.getPlayerBalance(sender.uniqueId, BalanceType.BANK_BALANCE)
|
||||
if (playerBalance.bankBalance == null) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to get your balance."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
if (amount == -1L) amount = playerBalance.bankBalance
|
||||
|
||||
if (amount > playerBalance.bankBalance) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Cannot withdraw <yellow>$amount <aqua>${if (amount == 1L) "Diamond" else "Diamonds"} <red>because your bank only contains <yellow>${playerBalance.bankBalance} <aqua>${if (playerBalance.bankBalance == 1L) "diamond" else "diamonds"}<red>."))
|
||||
return@launch
|
||||
}
|
||||
|
||||
DiamondBankOG.blockInventoryFor.add(sender.uniqueId)
|
||||
val emptySlots = sender.inventory.storageContents.filter { it == null }.size * 64
|
||||
val leftOverSpace = sender.inventory.storageContents.filterNotNull().filter { it.type == Material.DIAMOND }
|
||||
.sumOf { 64 - it.amount }
|
||||
if (amount > (emptySlots + leftOverSpace)) {
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>You don't have enough inventory space to withdraw <yellow>$amount <aqua>${if (amount == 1L) "Diamond" else "Diamonds"}<red>."))
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
return@launch
|
||||
}
|
||||
|
||||
var error = DiamondBankOG.postgreSQL.subtractFromPlayerBalance(
|
||||
sender.uniqueId,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
sender.uniqueId,
|
||||
PostgresFunction.SUBTRACT_FROM_PLAYER_BALANCE,
|
||||
amount,
|
||||
BalanceType.BANK_BALANCE,
|
||||
playerBalance,
|
||||
"withdraw"
|
||||
)
|
||||
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to withdraw."))
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
return@launch
|
||||
}
|
||||
|
||||
error = DiamondBankOG.postgreSQL.addToPlayerBalance(
|
||||
sender.uniqueId,
|
||||
amount,
|
||||
BalanceType.INVENTORY_BALANCE
|
||||
)
|
||||
if (error) {
|
||||
Helper.handleError(
|
||||
sender.uniqueId,
|
||||
PostgresFunction.ADD_TO_PLAYER_BALANCE,
|
||||
amount,
|
||||
BalanceType.INVENTORY_BALANCE,
|
||||
playerBalance,
|
||||
"withdraw"
|
||||
)
|
||||
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <red>Something went wrong while trying to withdraw."))
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
return@launch
|
||||
}
|
||||
sender.inventory.addItem(ItemStack(Material.DIAMOND, amount.toInt()))
|
||||
DiamondBankOG.blockInventoryFor.remove(sender.uniqueId)
|
||||
sender.sendMessage(DiamondBankOG.mm.deserialize("${Config.prefix}<reset>: <green>Successfully withdrew <yellow>$amount <aqua>${if (amount == 1L) "Diamond" else "Diamonds"} <green>from your bank account."))
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
# ---General---
|
||||
# MiniMessage-formatted prefix (https://docs.advntr.dev/minimessage/format.html)
|
||||
prefix: <dark_gray>[<aqua>DiamondBank<white>-<dark_red>OG<dark_gray>]
|
||||
|
||||
# ---Sentry (or compatible services like GlitchTip)---
|
||||
sentryEnabled: false
|
||||
sentryDsn: Sentry(-compatible) DSN URL
|
||||
|
||||
# ---Postgres---
|
||||
postgresUrl: jdbc:postgresql://localhost:5432/diamond
|
||||
postgresUser: postgres
|
||||
postgresPassword: postgresPassword
|
||||
postgresTable: diamond
|
||||
@@ -1,38 +0,0 @@
|
||||
name: DiamondBank-OG
|
||||
version: '${version}'
|
||||
main: net.trueog.diamondbankog.DiamondBankOG
|
||||
api-version: '${apiVersion}'
|
||||
commands:
|
||||
deposit:
|
||||
description: Deposit diamonds into your bank
|
||||
usage: /deposit <amount> or /deposit all
|
||||
withdraw:
|
||||
description: Withdraw diamonds from your bank
|
||||
usage: /withdraw <amount> or /withdraw all
|
||||
setbankbalance:
|
||||
description: Set the bank balance of a player
|
||||
usage: /setbankbalance <player name or player uuid> <amount>
|
||||
setbankbal:
|
||||
description: Set the bank balance of a player
|
||||
usage: /setbankbal <player name or player uuid> <amount>
|
||||
pay:
|
||||
description: Pay a player
|
||||
usage: /pay <player name or player uuid> <amount>
|
||||
balancetop:
|
||||
description: Show the balancetop
|
||||
usage: /balancetop <page number (optional)>
|
||||
baltop:
|
||||
description: Show the balancetop
|
||||
usage: /baltop <page number (optional)>
|
||||
balance:
|
||||
description: Get your or someone else's balance
|
||||
usage: /balance or /balance <player name or player uuid>
|
||||
bal:
|
||||
description: Get your or someone else's balance
|
||||
usage: /bal or /bal <player name or player uuid>
|
||||
diamondbankreload:
|
||||
description: Reload the config
|
||||
usage: /diamondbankreload
|
||||
|
||||
# So we can overwrite Essentials' commands
|
||||
softdepend: [ Essentials ]
|
||||
@@ -1,11 +0,0 @@
|
||||
target/
|
||||
out/
|
||||
.idea/
|
||||
*.iml
|
||||
*.class
|
||||
.gradle/
|
||||
build/
|
||||
bin/
|
||||
.classpath
|
||||
.settings/
|
||||
.project
|
||||
@@ -1,24 +0,0 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
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 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.
|
||||
|
||||
For more information, please refer to <https://unlicense.org>
|
||||
@@ -1,3 +0,0 @@
|
||||
# GxUI
|
||||
|
||||
My GUI Lib. To use, use the following repo URL: `https://repo.hotten.cloud/releases`, the following package: `uk.hotten.gxui`, and artifact: `gxui:1.3.1`.
|
||||
@@ -1,118 +0,0 @@
|
||||
plugins {
|
||||
|
||||
id 'java' // Tell gradle this is a java project.
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' // Import utility to package libraries into .jar file.
|
||||
id 'eclipse' // Import eclipse plugin for IDE integration.
|
||||
id 'maven-publish' // Import maven publish repo for Jitpack.
|
||||
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
// Declare java version.
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
}
|
||||
|
||||
group = "uk.hotten.gxui" // Declare bundle identifier.
|
||||
version = "1.3.1" // Declare plugin version (will be in .jar).
|
||||
|
||||
def apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
processResources {
|
||||
|
||||
def props = [
|
||||
version: version,
|
||||
apiVersion: apiVersion,
|
||||
]
|
||||
|
||||
inputs.properties props // Indicates to rerun if version changes.
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
|
||||
expand props
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
repositories {
|
||||
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
|
||||
url "https://repo.purpurmc.org/snapshots" // Get purpur API from purpur maven repository.
|
||||
|
||||
}
|
||||
|
||||
maven {
|
||||
|
||||
url "https://jitpack.io"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly "org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT" // Declare purpur API version to be packaged.
|
||||
implementation 'com.github.cnie109:Utilities-OG:c1c6c4ac33' // Import Utilities-OG API.
|
||||
|
||||
// Import project lombok.
|
||||
compileOnly 'org.projectlombok:lombok:1.18.30'
|
||||
annotationProcessor 'org.projectlombok:lombok:1.18.30'
|
||||
|
||||
testCompileOnly 'org.projectlombok:lombok:1.18.30'
|
||||
testAnnotationProcessor 'org.projectlombok:lombok:1.18.30'
|
||||
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
||||
minimize()
|
||||
|
||||
}
|
||||
|
||||
jar.dependsOn shadowJar
|
||||
|
||||
tasks.jar.configure {
|
||||
|
||||
archiveClassifier = "part"
|
||||
|
||||
}
|
||||
|
||||
tasks.shadowJar.configure {
|
||||
|
||||
archiveClassifier = null
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
|
||||
options.compilerArgs += ["-parameters"]
|
||||
options.encoding = 'UTF-8' // Override the system character set with a universal set.
|
||||
options.fork = true // Enable compilation in a separate daemon process.
|
||||
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "hottenRepo"
|
||||
url = "https://repo.hotten.cloud/releases"
|
||||
credentials(PasswordCredentials)
|
||||
authentication {
|
||||
basic(BasicAuthentication)
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
groupId = "uk.hotten.gxui"
|
||||
artifactId = "gxui"
|
||||
version = "1.3.1"
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
Vendored
-249
@@ -1,249 +0,0 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# 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/subprojects/plugins/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 "${APP_HOME:-./}" > /dev/null && pwd -P ) || 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=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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, 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" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# 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
-92
@@ -1,92 +0,0 @@
|
||||
@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
|
||||
|
||||
@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.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = "GxGUI"
|
||||
@@ -1,323 +0,0 @@
|
||||
package uk.hotten.gxui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public abstract class GUIBase implements Listener {
|
||||
|
||||
private JavaPlugin plugin;
|
||||
|
||||
private HashMap<Integer, GUIItem> inventoryContents;
|
||||
|
||||
@Getter private String inventoryName;
|
||||
@Getter private int inventorySize;
|
||||
@Getter private boolean fillEmpty;
|
||||
|
||||
@Getter private Sound openSound;
|
||||
@Getter private float openSoundFloat;
|
||||
@Getter private Sound errorSound;
|
||||
@Getter private float errorSoundFloat;
|
||||
|
||||
@Getter private Player player;
|
||||
|
||||
private Inventory inventory;
|
||||
|
||||
private boolean isOpen = false; // prevents accidental un-registration from other GUIs that have the same name
|
||||
|
||||
private HashMap<Integer, String> itemErrors;
|
||||
private HashMap<Integer, Integer> itemTimings;
|
||||
|
||||
public GUIBase(JavaPlugin plugin, Player player, String inventoryName, int inventorySize, boolean fillEmpty) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.inventoryName = inventoryName;
|
||||
this.inventorySize = inventorySize;
|
||||
this.fillEmpty = fillEmpty;
|
||||
inventoryContents = new HashMap<>();
|
||||
|
||||
openSound = null;
|
||||
|
||||
errorSound = Sound.ENTITY_ITEM_BREAK;
|
||||
errorSoundFloat = (float) 0.6;
|
||||
|
||||
itemErrors = new HashMap<>();
|
||||
itemTimings = new HashMap<>();
|
||||
}
|
||||
|
||||
public GUIBase(JavaPlugin plugin, Player player, String inventoryName, int inventorySize, boolean fillEmpty, Sound openSound, float openSoundFloat, Sound errorSound, float errorSoundFloat) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.inventoryName = inventoryName;
|
||||
this.inventorySize = inventorySize;
|
||||
this.fillEmpty = fillEmpty;
|
||||
inventoryContents = new HashMap<>();
|
||||
|
||||
this.openSound = openSound;
|
||||
this.openSoundFloat = openSoundFloat;
|
||||
|
||||
this.errorSound = errorSound;
|
||||
this.errorSoundFloat = errorSoundFloat;
|
||||
|
||||
itemErrors = new HashMap<>();
|
||||
itemTimings = new HashMap<>();
|
||||
}
|
||||
|
||||
public void open(boolean refresh) {
|
||||
if (! isOpen)
|
||||
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
if (openSound != null)
|
||||
player.playSound(player.getLocation(), openSound, 100f, openSoundFloat);
|
||||
isOpen = true;
|
||||
|
||||
Inventory playersInventory = player.getInventory();
|
||||
InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize(inventoryName);
|
||||
inventory = Bukkit.createInventory(inventoryContainer, inventorySize, nameHandler);
|
||||
|
||||
inventoryContents.clear();
|
||||
setupItems();
|
||||
|
||||
for (Map.Entry<Integer, GUIItem> i : inventoryContents.entrySet()) {
|
||||
inventory.setItem(i.getKey(), i.getValue().build());
|
||||
}
|
||||
|
||||
if (fillEmpty) {
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
inventory.setItem(i, fillSlot());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.openInventory(inventory);
|
||||
|
||||
if (refresh) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Inventory inventory = ((HumanEntity) player).getOpenInventory().getTopInventory();
|
||||
Component inventoryTitle = player.getOpenInventory().title();
|
||||
String inventoryTitleText = inventoryTitle.examinableName();
|
||||
if (! inventoryTitleText.equalsIgnoreCase(inventoryName)) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
inventory.clear();
|
||||
inventoryContents.clear();
|
||||
setupItems();
|
||||
int counter = 0;
|
||||
for (Map.Entry<Integer, GUIItem> i : inventoryContents.entrySet()) {
|
||||
if (itemErrors.containsKey(i.getKey())) {
|
||||
|
||||
GUIItem error = new GUIItem(Material.RED_STAINED_GLASS_PANE, 1, addLinebreaks(itemErrors.get(i.getKey()), 30, "&7").get(counter), "&c&lERROR");
|
||||
|
||||
counter++;
|
||||
int tick = itemTimings.get(i.getKey());
|
||||
tick++;
|
||||
itemTimings.remove(i.getKey());
|
||||
itemTimings.put(i.getKey(), tick);
|
||||
|
||||
if (tick >= 9) {
|
||||
itemErrors.remove(i.getKey());
|
||||
itemTimings.remove(i.getKey());
|
||||
inventory.setItem(i.getKey(), i.getValue().build());
|
||||
continue;
|
||||
}
|
||||
|
||||
inventory.setItem(i.getKey(), error.build());
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
inventory.setItem(i.getKey(), i.getValue().build());
|
||||
|
||||
}
|
||||
|
||||
if (fillEmpty) {
|
||||
for (int i = 0; i<inventorySize; i++) {
|
||||
if (inventory.getItem(i) == null) {
|
||||
inventory.setItem(i, fillSlot());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(plugin, 0, 5);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void setupItems();
|
||||
|
||||
public static ArrayList<TextComponent> convertToTextComponents(List<String> stringList) {
|
||||
ArrayList<TextComponent> textComponents = new ArrayList<>();
|
||||
|
||||
for (String str : stringList) {
|
||||
TextComponent textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(str);
|
||||
textComponents.add(textComponent);
|
||||
}
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
|
||||
public void addItem(Integer slot, GUIItem item) {
|
||||
inventoryContents.put(slot, item);
|
||||
}
|
||||
|
||||
private ItemStack fillSlot() {
|
||||
ItemStack i = new ItemStack(Material.GRAY_STAINED_GLASS_PANE, 1);
|
||||
ItemMeta m = i.getItemMeta();
|
||||
TextComponent emptySlotDisplayName = LegacyComponentSerializer.legacyAmpersand().deserialize(" ");
|
||||
m.displayName(emptySlotDisplayName);
|
||||
i.setItemMeta(m);
|
||||
return i;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent event) {
|
||||
if(event.getItemDrop().getItemStack().getItemMeta().isUnbreakable()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/*@EventHandler
|
||||
public void inventoryClickHandler(InventoryClickEvent e) {
|
||||
Player p = (Player) e.getWhoClicked();
|
||||
Inventory i = e.getClickedInventory();
|
||||
if(e.getCurrentItem().getItemMeta().isUnbreakable()) {
|
||||
if(i.getTitle() != p.getInventory().getTitle()) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
@EventHandler
|
||||
public void inventoryDragHandler(InventoryDragEvent event) {
|
||||
if(event.getCursor().getItemMeta().isUnbreakable()) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerInventoryClickHandler(InventoryClickEvent event) {
|
||||
Player clickedPlayer = (Player) event.getWhoClicked();
|
||||
ClickType clickType = event.getClick();
|
||||
Inventory inventory = event.getClickedInventory();
|
||||
ItemStack item = event.getCurrentItem();
|
||||
Component inventoryName = event.getView().title();
|
||||
String inventoryTitleText = inventoryName.examinableName();
|
||||
|
||||
if (clickedPlayer != player)
|
||||
return;
|
||||
|
||||
if (inventory == null)
|
||||
return;
|
||||
|
||||
if (inventoryTitleText.equalsIgnoreCase(inventoryName.examinableName())) {
|
||||
if (item == null || ! item.hasItemMeta() || item.getItemMeta().displayName().equals(LegacyComponentSerializer.legacyAmpersand().deserialize(" "))) {
|
||||
if (errorSound != null)
|
||||
player.playSound(player.getLocation(), errorSound, 50f, errorSoundFloat);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemErrors.containsKey(event.getSlot())) {
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 50f, 0.7f);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inventoryContents.containsKey(event.getSlot())) {
|
||||
GUIItem guiItem = inventoryContents.get(event.getSlot());
|
||||
event.setCancelled(true);
|
||||
|
||||
if (! guiItem.isButton()) {
|
||||
if (guiItem.isPlayErrorSound() && errorSound != null)
|
||||
player.playSound(player.getLocation(), errorSound, 50f, errorSoundFloat);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
boolean exec = guiItem.executeClick(clickType);
|
||||
if (! exec) {
|
||||
if (guiItem.isPlayErrorSound() && errorSound != null)
|
||||
player.playSound(player.getLocation(), errorSound, 100f, errorSoundFloat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void close(InventoryCloseEvent event) {
|
||||
Player closer = (Player) event.getPlayer();
|
||||
Component inventoryTitle = player.getOpenInventory().title();
|
||||
String inventoryTitleText = inventoryTitle.examinableName();
|
||||
if (inventoryTitleText.equalsIgnoreCase(inventoryName) && isOpen) {
|
||||
if (closer == player) {
|
||||
HandlerList.unregisterAll(this);
|
||||
isOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showErrorItem(Player player, Integer item, String error, boolean sound) {
|
||||
itemErrors.put(item, error);
|
||||
itemTimings.put(item, 0);
|
||||
if (sound)
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 100f, 0.7f);
|
||||
}
|
||||
|
||||
public ArrayList<String> addLinebreaks(String input, int maxLineLength, String toAppendAfterNewline) {
|
||||
ArrayList<String> result = new ArrayList<>();
|
||||
|
||||
StringTokenizer tok = new StringTokenizer(input, " ");
|
||||
StringBuilder output = new StringBuilder();
|
||||
output.insert(0, toAppendAfterNewline);
|
||||
int lineLen = 0;
|
||||
while (tok.hasMoreTokens()) {
|
||||
String word = tok.nextToken();
|
||||
|
||||
if (lineLen + word.length() > maxLineLength) {
|
||||
result.add(output.toString());
|
||||
output = new StringBuilder();
|
||||
output.append(toAppendAfterNewline);
|
||||
lineLen = 0;
|
||||
}
|
||||
output.append(word).append(" ");
|
||||
lineLen += word.length();
|
||||
}
|
||||
result.add(output.toString());
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package uk.hotten.gxui;
|
||||
|
||||
public abstract interface GUIButton {
|
||||
|
||||
public abstract boolean leftClick();
|
||||
public abstract boolean leftClickShift();
|
||||
public abstract boolean rightClick();
|
||||
public abstract boolean rightClickShift();
|
||||
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
name: GxGUI
|
||||
author: Gxorge
|
||||
description: Gxorge's GUI library updated for 1.19 by TrueOG Network
|
||||
website: https://github.com/Gxorge/GxGUI
|
||||
version: '${version}'
|
||||
api-version: '${apiVersion}'
|
||||
main: uk/hotten/gxui
|
||||
@@ -1,121 +0,0 @@
|
||||
# User-specific stuff
|
||||
.idea/
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
out/
|
||||
bin/
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Compiled class file
|
||||
*.class
|
||||
|
||||
# Log file
|
||||
*.log
|
||||
|
||||
# BlueJ files
|
||||
*.ctxt
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.nar
|
||||
*.ear
|
||||
*.zip
|
||||
*.tar.gz
|
||||
*.rar
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
*~
|
||||
|
||||
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||
.fuse_hidden*
|
||||
|
||||
# KDE directory preferences
|
||||
.directory
|
||||
|
||||
# Linux trash folder which might appear on any partition or disk
|
||||
.Trash-*
|
||||
|
||||
# .nfs files are created when an open file is removed but is still being accessed
|
||||
.nfs*
|
||||
|
||||
# General
|
||||
.DS_Store
|
||||
.AppleDouble
|
||||
.LSOverride
|
||||
|
||||
# Icon must end with two \r
|
||||
Icon
|
||||
|
||||
# Thumbnails
|
||||
._*
|
||||
|
||||
# Files that might appear in the root of a volume
|
||||
.DocumentRevisions-V100
|
||||
.fseventsd
|
||||
.Spotlight-V100
|
||||
.TemporaryItems
|
||||
.Trashes
|
||||
.VolumeIcon.icns
|
||||
.com.apple.timemachine.donotpresent
|
||||
|
||||
# Directories potentially created on remote AFP share
|
||||
.AppleDB
|
||||
.AppleDesktop
|
||||
Network Trash Folder
|
||||
Temporary Items
|
||||
.apdisk
|
||||
|
||||
# Windows thumbnail cache files
|
||||
Thumbs.db
|
||||
Thumbs.db:encryptable
|
||||
ehthumbs.db
|
||||
ehthumbs_vista.db
|
||||
|
||||
# Dump file
|
||||
*.stackdump
|
||||
|
||||
# Folder config file
|
||||
[Dd]esktop.ini
|
||||
|
||||
# Recycle Bin used on file shares
|
||||
$RECYCLE.BIN/
|
||||
|
||||
# Windows Installer files
|
||||
*.cab
|
||||
*.msi
|
||||
*.msix
|
||||
*.msm
|
||||
*.msp
|
||||
|
||||
# Windows shortcuts
|
||||
*.lnk
|
||||
|
||||
.gradle
|
||||
build/
|
||||
|
||||
# Ignore Gradle GUI config
|
||||
gradle-app.setting
|
||||
|
||||
# Cache of project
|
||||
.gradletasknamecache
|
||||
|
||||
**/build/
|
||||
|
||||
# Common working directory
|
||||
run/
|
||||
|
||||
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
|
||||
!gradle-wrapper.jar
|
||||
@@ -1,24 +0,0 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
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 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.
|
||||
|
||||
For more information, please refer to <https://unlicense.org>
|
||||
@@ -1,54 +0,0 @@
|
||||
# Utilities-OG
|
||||
|
||||
Current Target: Purpur 1.19.4
|
||||
|
||||
Authors: Barny1094875.
|
||||
|
||||
<h3>To build:</h3>
|
||||
|
||||
./gradlew build
|
||||
|
||||
The resulting .jar file will be in build/libs
|
||||
|
||||
This plugin houses various little tweaks used by the TrueOG Minecraft server.
|
||||
|
||||
At the moment, any config change requires a server restart to take effect.
|
||||
|
||||
*Current Features*
|
||||
|
||||
- Phantom Toggle
|
||||
|
||||
Use /utilites togglephantoms to disable phantom spawning. Use it again to enable phantom spawning.
|
||||
*Requires utilities.togglephantoms permission.*
|
||||
|
||||
- Entity Cramming Disable
|
||||
|
||||
Use /utilites togglecramming to disable entity cramming. use it again to enable entity cramming.
|
||||
*Requires utilities.togglecramming permission.*
|
||||
|
||||
- Ranks Menu
|
||||
|
||||
Use /utilities ranks to show the TrueOG store menu.
|
||||
*Requires utilities.ranks permission.*
|
||||
|
||||
- Ping Menu
|
||||
|
||||
Use /utilities ping to show your own ping, or /utilities ping <player> to show someone else's.
|
||||
Also includes /bing which replicates the functionality of the default /ping in minecraft.
|
||||
*Requires utilities.ping permission.*
|
||||
|
||||
- Bamboo Wood
|
||||
|
||||
Allows crafting of bamboo wood prior to 1.20
|
||||
|
||||
- Chainmail Armour
|
||||
|
||||
Allows the crafting of chainmail armour with chains
|
||||
|
||||
- NoFlippy
|
||||
|
||||
Plugin made by NotAlexNoyle that has been merged in here. Prevents trapdoors being flipped in certain regions by certain groups
|
||||
|
||||
- ColorCodes
|
||||
|
||||
Another of NotAlexNoyle's plugins merged here. Reveals bukkit's color codes for chat formatting
|
||||
@@ -1,101 +0,0 @@
|
||||
plugins {
|
||||
|
||||
id 'java' // Tell gradle this is a java project.
|
||||
id 'com.github.johnrengelman.shadow' version '8.1.1' // Import utility to package libraries into .jar file.
|
||||
id 'eclipse' // Import eclipse plugin for IDE integration.
|
||||
id 'org.jetbrains.kotlin.jvm' version '1.9.23' // Import kotlin jvm plugin for kotlin/java integration.
|
||||
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
// Declare java version.
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
}
|
||||
|
||||
group = 'me.barny1094875'
|
||||
version = '2.1.1'
|
||||
|
||||
def apiVersion = "1.19" // Declare minecraft server target version.
|
||||
|
||||
processResources {
|
||||
|
||||
def props = [
|
||||
version: version,
|
||||
apiVersion: apiVersion,
|
||||
]
|
||||
|
||||
inputs.properties props // Indicates to rerun if version changes.
|
||||
|
||||
filesMatching("plugin.yml") {
|
||||
|
||||
expand props
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
|
||||
mavenCentral()
|
||||
|
||||
maven {
|
||||
|
||||
url "https://repo.purpurmc.org/snapshots" // Get purpur API from purpur maven repository.
|
||||
|
||||
}
|
||||
|
||||
maven {
|
||||
|
||||
name = "CodeMC"
|
||||
url = uri("https://repo.codemc.io/repository/maven-public/")
|
||||
|
||||
}
|
||||
|
||||
maven {
|
||||
|
||||
name 'enginehub-repo' // Declare a name for the EngineHub repository.
|
||||
url 'https://maven.enginehub.org/repo/' // Import EngineHub repository for WorldGuard API.
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
compileOnly "org.purpurmc.purpur:purpur-api:1.19.4-R0.1-SNAPSHOT" // Declare purpur API version to be packaged.
|
||||
compileOnly "com.sk89q.worldguard:worldguard-bukkit:7.0.8"
|
||||
compileOnly 'de.tr7zw:item-nbt-api-plugin:2.11.2'
|
||||
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8' // Declare kotlin library to be packaged.
|
||||
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
|
||||
minimize()
|
||||
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
||||
def props = [version: version]
|
||||
inputs.properties props
|
||||
|
||||
filteringCharset 'UTF-8'
|
||||
filesMatching('plugin.yml') {
|
||||
|
||||
expand props
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile).configureEach {
|
||||
|
||||
options.compilerArgs += ["-parameters"]
|
||||
options.encoding = 'UTF-8' // Override the system character set with a universal set.
|
||||
options.fork = true // Enable compilation in a separate daemon process.
|
||||
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
**1.3.2**:
|
||||
- Refactor phantom toggle logic.
|
||||
- Enable phantom spawning by default.
|
||||
- Fix Jitpack build.
|
||||
|
||||
**1.3.1:**
|
||||
- Make bamboo wood named bamboo wood.
|
||||
|
||||
**1.3:**
|
||||
|
||||
- Added new /ping command. Supports ping lookup for self and others.
|
||||
- Added /bing command to replicate the functionality of the old /ping command.
|
||||
- Renamed /buy to /ranks for CraftingStore compatibility.
|
||||
- Copied sub-commands as root commands.
|
||||
- New per-command permissions (described in README.md).
|
||||
- Added ranks menu and ping API.
|
||||
|
||||
**1.2:**
|
||||
|
||||
- Add "bamboo" wood recipe.
|
||||
|
||||
**1.1:**
|
||||
|
||||
- Added about message.
|
||||
- Fixed NullPointerException.
|
||||
- Expanded documentation.
|
||||
- Improved chat formatting.
|
||||
- Block per-player commands from console.
|
||||
- Merged in and deprecated Buy-OG.
|
||||
Whitespace-only changes.
Binary file not shown.
@@ -1,6 +0,0 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
|
||||
networkTimeout=10000
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
Vendored
-245
@@ -1,245 +0,0 @@
|
||||
#!/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.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# 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/subprojects/plugins/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##*/}
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || 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=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
||||
|
||||
|
||||
# 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
|
||||
which java >/dev/null 2>&1 || 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
|
||||
|
||||
# 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=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=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 $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
-classpath "$CLASSPATH" \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# 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
-92
@@ -1,92 +0,0 @@
|
||||
@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
|
||||
|
||||
@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.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@@ -1,7 +0,0 @@
|
||||
jdk:
|
||||
- 17.0.8
|
||||
before_install:
|
||||
- sdk install java 17.0.8-graalce
|
||||
- sdk use java 17.0.8-graalce
|
||||
install:
|
||||
- ./gradlew build publishToMavenLocal
|
||||
@@ -1 +0,0 @@
|
||||
rootProject.name = 'Utilities-OG'
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.Listeners;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
|
||||
// Import required libraries.
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
|
||||
public class DisableEntityCramming implements Listener {
|
||||
|
||||
// Listen for entities being damaged.
|
||||
@EventHandler
|
||||
public void disableEntityCramming(EntityDamageEvent event) {
|
||||
|
||||
// If the damage is caused by entity cramming, do this...
|
||||
if(event.getCause().equals(DamageCause.CRAMMING)) {
|
||||
|
||||
// If disabling entity cramming is set to "true" in config.yml, do this...
|
||||
if(Utilities_OG.config().getBoolean("disableEntityCramming")) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.Listeners;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
|
||||
public class DisablePhantomSpawns implements Listener {
|
||||
|
||||
// Listen for mob spawning events.
|
||||
@EventHandler
|
||||
public void disablePhantomSpawns(CreatureSpawnEvent event) {
|
||||
// If the mob that spawned is a phantom, do this...
|
||||
if (event.getEntityType().equals(EntityType.PHANTOM)) {
|
||||
// Store the contents of phantomDisabledUsers.yml file as a YAML object.
|
||||
YamlConfiguration phantomsAreDisabled = Utilities_OG.getPhantomPreferences();
|
||||
// get every player currently on the server in the world that the phantom spawned
|
||||
for (Player player : Bukkit.getServer().getOnlinePlayers()
|
||||
.stream()
|
||||
.filter(p -> p.getWorld().equals(event.getEntity().getWorld()))
|
||||
.filter(p -> phantomsAreDisabled.getBoolean(p.getUniqueId().toString()))
|
||||
.toArray(Player[]::new)) {
|
||||
// Check if the phantom is close enough to the player to count as their spawn.
|
||||
if (event.getEntity().getLocation().distance(player.getLocation()) < 48) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,191 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog;
|
||||
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagConflictException;
|
||||
import com.sk89q.worldguard.protection.flags.registry.FlagRegistry;
|
||||
import me.barny1094875.utilitiesog.Listeners.DisableEntityCramming;
|
||||
import me.barny1094875.utilitiesog.Listeners.DisablePhantomSpawns;
|
||||
import me.barny1094875.utilitiesog.modules.*;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public final class Utilities_OG extends JavaPlugin {
|
||||
|
||||
private File file;
|
||||
private static Utilities_OG plugin;
|
||||
private static final MiniMessage mm = MiniMessage.miniMessage();
|
||||
private static FileConfiguration config;
|
||||
private static File phantomPreferencesFile;
|
||||
private static YamlConfiguration phantomPreferences;
|
||||
private static StateFlag FlippyFlag;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
plugin = this;
|
||||
|
||||
this.file = new File(this.getDataFolder(), "config.yml");
|
||||
if (!this.file.exists()) {
|
||||
this.saveDefaultConfig();
|
||||
}
|
||||
|
||||
config = this.getConfig();
|
||||
|
||||
phantomPreferencesFile = new File(this.getDataFolder(), "phantomDisabledUsers.yml");
|
||||
try {
|
||||
if (!phantomPreferencesFile.exists()) {
|
||||
|
||||
phantomPreferencesFile.createNewFile();
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
||||
this.getLogger().severe("Something went wrong when creating the phantom toggle cache file!");
|
||||
|
||||
}
|
||||
|
||||
phantomPreferences = YamlConfiguration.loadConfiguration(phantomPreferencesFile);
|
||||
|
||||
// Set up each feature here, using the config to enable only that which is desired,
|
||||
// be sure to label, using comments, what each block is enabling.
|
||||
|
||||
// Enable the Phantom Toggle Module.
|
||||
if (this.getConfig().getBoolean("PhantomToggle")) {
|
||||
// Activate the Phantom Toggle Listener.
|
||||
getServer().getPluginManager().registerEvents(new DisablePhantomSpawns(), this);
|
||||
// Activate the Phantom Toggle Command.
|
||||
this.getCommand("togglephantoms").setExecutor(new PhantomToggleModule());
|
||||
}
|
||||
// Enable the Entity Cramming Toggle Module.
|
||||
if (this.getConfig().getBoolean("EntityCrammingDisable")) {
|
||||
// Activate the Entity Cramming Toggle Listener.
|
||||
getServer().getPluginManager().registerEvents(new DisableEntityCramming(), this);
|
||||
// Activate the Entity Cramming Toggle Command.
|
||||
this.getCommand("togglecramming").setExecutor(new EntityCrammingToggleModule());
|
||||
}
|
||||
// Enable the Ranks Module.
|
||||
if (this.getConfig().getBoolean("RanksMenu")) {
|
||||
// Activate the Ranks Command.
|
||||
this.getCommand("ranks").setExecutor(new RanksModule());
|
||||
}
|
||||
// Enable the Ping Module.
|
||||
if (this.getConfig().getBoolean("Ping")) {
|
||||
// Enable the Ping command.
|
||||
this.getCommand("ping").setExecutor(new PingModule());
|
||||
// Enable the Bing command (replicates old /ping functionality).
|
||||
this.getCommand("bing").setExecutor(new BingModule());
|
||||
}
|
||||
// Enable bamboo wood module
|
||||
if (this.getConfig().getBoolean("BambooWood")) {
|
||||
BambooWood.Enable();
|
||||
}
|
||||
// Enable chain armour module
|
||||
if (this.getConfig().getBoolean("ChainArmour")) {
|
||||
ChainArmour.Enable();
|
||||
}
|
||||
// Enable the ColorCodes module
|
||||
if (this.getConfig().getBoolean("ColorCodes")) {
|
||||
this.getCommand("colorcodes").setExecutor(new ColorCodes());
|
||||
}
|
||||
// Enable the NoFlippy module
|
||||
if (this.getConfig().getBoolean("NoFlippy")) {
|
||||
// check that WorldGuard is installed
|
||||
if (getServer().getPluginManager().getPlugin("WorldGuard") == null) {
|
||||
this.getLogger().severe("WorldGuard is not installed! Disabling NoFlippy...");
|
||||
} else {
|
||||
// Activate the NoFlippy Listener.
|
||||
getServer().getPluginManager().registerEvents(new NoFlippy(), this);
|
||||
}
|
||||
}
|
||||
|
||||
// Register the primary /utilities command.
|
||||
this.getCommand("utilities").setExecutor(new AboutModule());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
|
||||
// Add the WorldGuard flag for an area where NoFlippy is active.
|
||||
FlagRegistry registry = WorldGuard.getInstance().getFlagRegistry();
|
||||
try {
|
||||
|
||||
// Create a flag with the name "my-custom-flag", defaulting to true.
|
||||
StateFlag flag = new StateFlag("can-flippy", true);
|
||||
|
||||
// Register the new flag with WorldGuard.
|
||||
registry.register(flag);
|
||||
|
||||
// Only set the field if there was no error.
|
||||
FlippyFlag = flag;
|
||||
|
||||
} catch (FlagConflictException e) {
|
||||
|
||||
// Some other plugin registered a flag by the same name already.
|
||||
// You can use the existing flag, but this may cause conflicts - be sure to check type.
|
||||
Flag<?> existing = registry.get("can-flippy");
|
||||
if (existing instanceof StateFlag) {
|
||||
|
||||
FlippyFlag = (StateFlag) existing;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Rank menu API.
|
||||
public RanksModule ranksCommand() {
|
||||
return new RanksModule();
|
||||
}
|
||||
|
||||
// Ping API.
|
||||
public PingModule pingCommand() {
|
||||
return new PingModule();
|
||||
}
|
||||
|
||||
public static Utilities_OG getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public static FileConfiguration config() {
|
||||
return config;
|
||||
}
|
||||
|
||||
public static MiniMessage getMM() {
|
||||
return mm;
|
||||
}
|
||||
|
||||
public static YamlConfiguration getPhantomPreferences() {
|
||||
return phantomPreferences;
|
||||
}
|
||||
|
||||
public static File getPhantomDisabledPlayersFile() {
|
||||
return phantomPreferencesFile;
|
||||
}
|
||||
|
||||
// Share FlippyFlag with Listeners.
|
||||
public static StateFlag getFlippyFlag() {
|
||||
return FlippyFlag;
|
||||
}
|
||||
|
||||
// Runs plugin asynchronously so multiple players can use it at once efficiently.
|
||||
public BukkitTask runTaskAsynchronously(final Runnable run) {
|
||||
|
||||
// Schedule Processes.
|
||||
return this.getServer().getScheduler().runTaskAsynchronously(this, run);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class AboutModule implements CommandExecutor
|
||||
{
|
||||
// Command execution event handler extending bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Send formatted about message using MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#FFAA00>A collection of small utilities used by <#00AA00>True<#AA0000>OG<#FFAA00> <#FFFF55>Network<#FFAA00>. Developed by <#FFFF55>christianniehaus <#FFAA00>& <#FFFF55>NotAlexNoyle<#FFAA00>.");
|
||||
player.sendMessage(parsed);
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage("ERROR: The console cannot execute this command! Join the server in-game and try again.");
|
||||
}
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
|
||||
public class BambooWood {
|
||||
|
||||
public static void Enable() {
|
||||
ItemStack bambooWood = new ItemStack(Material.OAK_PLANKS);
|
||||
ItemMeta bambooWoodMeta = bambooWood.getItemMeta();
|
||||
bambooWoodMeta.displayName(Utilities_OG.getMM().deserialize("Bamboo Wood").decoration(TextDecoration.ITALIC, false));
|
||||
bambooWood.setItemMeta(bambooWoodMeta);
|
||||
ShapedRecipe BambooWood = new ShapedRecipe(new NamespacedKey(Utilities_OG.getPlugin(), "Bamboo_Wood"),
|
||||
bambooWood)
|
||||
.shape("bb", "bb")
|
||||
.setIngredient('b', Material.BAMBOO);
|
||||
Bukkit.addRecipe(BambooWood);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
// Initialize command manager class.
|
||||
public class BingModule implements CommandExecutor
|
||||
{
|
||||
|
||||
// Command execution event handler extending bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Send player a connection confirmation message.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#FFFFFF> Bong!");
|
||||
player.sendMessage(parsed);
|
||||
}
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.ShapedRecipe;
|
||||
|
||||
public class ChainArmour {
|
||||
|
||||
public static void Enable() {
|
||||
ShapedRecipe ChainHelmet = new ShapedRecipe(new NamespacedKey(Utilities_OG.getPlugin(), "Chainmail_Helmet1"),
|
||||
new ItemStack(Material.CHAINMAIL_HELMET))
|
||||
.shape("ccc", "c c")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
Bukkit.addRecipe(ChainHelmet);
|
||||
|
||||
// recipe for chain chestplate
|
||||
ShapedRecipe ChainChestPlate = new ShapedRecipe(new NamespacedKey(Utilities_OG.getPlugin(), "Chainmail_Chestplate"),
|
||||
new ItemStack(Material.CHAINMAIL_CHESTPLATE))
|
||||
.shape("c c", "ccc", "ccc")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
Bukkit.addRecipe(ChainChestPlate);
|
||||
|
||||
// recipe for chain leggings
|
||||
ShapedRecipe ChainLeggings = new ShapedRecipe(new NamespacedKey(Utilities_OG.getPlugin(), "Chainmail_Leggings"),
|
||||
new ItemStack(Material.CHAINMAIL_LEGGINGS))
|
||||
.shape("ccc", "c c", "c c")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
Bukkit.addRecipe(ChainLeggings);
|
||||
|
||||
// recipe for chain boots
|
||||
ShapedRecipe ChainBoots = new ShapedRecipe(new NamespacedKey(Utilities_OG.getPlugin(), "Chainmail_Boots1"),
|
||||
new ItemStack(Material.CHAINMAIL_BOOTS))
|
||||
.shape("c c", "c c")
|
||||
.setIngredient('c', Material.CHAIN);
|
||||
Bukkit.addRecipe(ChainBoots);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class ColorCodes implements CommandExecutor {
|
||||
|
||||
// Create instance of class for command runner.
|
||||
private static ColorCodes instance;
|
||||
|
||||
// Constructor for main class to get instance from.
|
||||
public static ColorCodes getInstance() {
|
||||
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
// If the command matches our criteria, do this...
|
||||
if (cmd.getName().equalsIgnoreCase("colorcodes")) {
|
||||
|
||||
// If the command executor is a player, do this...
|
||||
if (sender instanceof Player) {
|
||||
|
||||
// Cast the sender to a player object safely.
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Send the color code cheat sheet to the player.
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<dark_aqua><bold>-=-=-=-=- <dark_purple>C<dark_aqua>o<green>l<yellow>o<red>r <aqua>C<light_purple>o<white>d<light_purple>e<aqua>s: -=-=-=-=-"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&0 = <black>Black <reset> &1 = <dark_blue>Dark Blue"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&2 = <dark_green>Dark Green <reset> &3 = <dark_aqua>Dark Aqua"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&4 = <dark_red>Dark Red <reset> &5 = <dark_purple>Dark Purple"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&6 = <gold>Gold <reset> &7 = <gray>Grey"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&8 = <dark_gray>Dark Grey <reset> &9 = <blue>Blue"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&a = <green>Green <reset> &b = <aqua>Aqua"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&c = <red>Red <reset> &d = <light_purple>Light Purple"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&e = <yellow>Yellow <reset> &f = <white>White"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&k = <obfuscated>Magic <reset> &l = <bold>Bold"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&m = <strikethrough>Strikethrough <reset> &n = <underlined>Underline"));
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("&o = <italic>Italic <reset> &r = Reset"));
|
||||
}
|
||||
// If the command executor is not a player, do this...
|
||||
else {
|
||||
|
||||
// Deny console executions.
|
||||
sender.sendMessage("ERROR: The console cannot execute this command!");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-42
@@ -1,42 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
//Import required libraries.
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class EntityCrammingToggleModule implements CommandExecutor
|
||||
{
|
||||
// Command execution event handler extending bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
// If the command runner has permission to toggle entity cramming, do this...
|
||||
if (player.hasPermission("utilities.togglecramming"))
|
||||
{
|
||||
// Fetch config file from data folder.
|
||||
FileConfiguration config = Utilities_OG.getPlugin().getConfig();
|
||||
|
||||
// Flip the true/false value to the opposite of what it currently is.
|
||||
config.set("doEntityCramming", ! config.getBoolean("doEntityCramming"));
|
||||
|
||||
// Send formatted confirmation message using MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#FFAA00>Entity cramming has been set to <#FFFF55>" + config.getBoolean("doEntityCramming") + "<#FFAA00>.");
|
||||
player.sendMessage(parsed);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
|
||||
public class NoFlippy implements Listener {
|
||||
|
||||
// Declare instance of class as static so multiple players can use it.
|
||||
private static NoFlippy instance;
|
||||
|
||||
// Return instance of class as static so multiple players can use it.
|
||||
public static NoFlippy getInstance() {
|
||||
|
||||
// Pass back Listeners to main.
|
||||
return instance;
|
||||
|
||||
}
|
||||
|
||||
// Listen for a player interacting with a trapdoor.
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
|
||||
// Get the nature of the interaction and store it.
|
||||
Action action = event.getAction();
|
||||
// Get the block that was interacted with and store it.
|
||||
Block blockClicked = event.getClickedBlock();
|
||||
// Get the player who interacted and store them.
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// Declare a container for the block type for null checking.
|
||||
String blockContainerAsString = null;
|
||||
try {
|
||||
|
||||
// Try storing the block type as a string. Throws NullPointerException if not applicable.
|
||||
blockContainerAsString = blockClicked.getType().toString();
|
||||
|
||||
} catch (NullPointerException error) {
|
||||
|
||||
// Do nothing if block type is null.
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// If the interaction was with a trap door, do this...
|
||||
if (blockContainerAsString.contains("TRAPDOOR")) {
|
||||
|
||||
// If the interaction was a right click, do this...
|
||||
if (action.isRightClick()) ;
|
||||
{
|
||||
|
||||
// If the player does not have permission to flip trap doors, do this...
|
||||
if (!player.hasPermission("noflippy.bypass")) {
|
||||
|
||||
Location blockLocation = BukkitAdapter.adapt(blockClicked.getLocation());
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
ApplicableRegionSet set = query.getApplicableRegions(blockLocation);
|
||||
|
||||
// If the Flippy Flag is set to DENY, cancel the event.
|
||||
if (!set.testState(null, Utilities_OG.getFlippyFlag())) {
|
||||
|
||||
// Cancel the trapdoor flip.
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
-72
@@ -1,72 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
// Import required libraries.
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
public class PhantomToggleModule implements CommandExecutor
|
||||
{
|
||||
// Command execution event handler extending bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (player.hasPermission("utilities.togglephantoms"))
|
||||
{
|
||||
// Store the contents of phantomDisabledUsers.yml file as a YAML object.
|
||||
YamlConfiguration phantomPreferences = Utilities_OG.getPhantomPreferences();
|
||||
|
||||
// Cherry pick the command runner's phantom status from the YAML data set.
|
||||
boolean phantomToggleState = phantomPreferences.getBoolean(player.getUniqueId().toString());
|
||||
|
||||
// Flip the true/false value to the opposite of what it currently is.
|
||||
phantomPreferences.set(player.getUniqueId().toString(), ! phantomToggleState);
|
||||
|
||||
// If the command sender's phantom spawning is turned on, do this...
|
||||
if (phantomToggleState)
|
||||
{
|
||||
// Send formatted "true" message using MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#55FF55>Phantom spawning turned <#00AA00>ON<#55FF55>.");
|
||||
player.sendMessage(parsed);
|
||||
}
|
||||
// If the command sender's phantom spawning is turned off, do this...
|
||||
else
|
||||
{
|
||||
// Send formatted "false" message using MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#FFAA00>Phantom spawning turned <#FF5555>OFF<#FFAA00>.");
|
||||
player.sendMessage(parsed);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
// Save changes to YAML data to disk.
|
||||
phantomPreferences.save(Utilities_OG.getPhantomDisabledPlayersFile());
|
||||
}
|
||||
catch (IOException error)
|
||||
{
|
||||
// Throw a runtime error if the YAML data could not be saved to disk.
|
||||
throw new RuntimeException(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
sender.sendMessage("ERROR: The console cannot execute this command! Join the server in-game and try again.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
// Initialize command manager class.
|
||||
public class PingModule implements CommandExecutor
|
||||
{
|
||||
|
||||
// Command execution event handler extending bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args)
|
||||
{
|
||||
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (player.hasPermission("utilities.ping"))
|
||||
{
|
||||
|
||||
// If the player did not provide any arguments, do this...
|
||||
if(args.length == 0) {
|
||||
|
||||
// Send player their own ping using a formatted message with the MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#00AA00>Your current ping is: <#FFAA00>" + player.getPing() + "<#00AA00>.");
|
||||
player.sendMessage(parsed);
|
||||
|
||||
}
|
||||
// If the player provided one or more arguments, do this...
|
||||
else if(args.length == 1) {
|
||||
|
||||
// Try to get the player that was specified.
|
||||
Player target = Bukkit.getPlayer(args[0]);
|
||||
|
||||
// If the provided argument was a valid player, do this...
|
||||
if(target != null) {
|
||||
|
||||
// Send player their specified player's ping using formatting with the MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#00AA00>" + target.getName() + "'s current ping is: <#FFAA00>" + target.getPing() + "<#00AA00>.");
|
||||
player.sendMessage(parsed);
|
||||
|
||||
}
|
||||
// If the provided argument was not a valid player, do this...
|
||||
else {
|
||||
|
||||
// Send a "player not found" error message using formatting with the MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#AA0000> ERROR: The player " + args[0] + " was not found!");
|
||||
player.sendMessage(parsed);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// If there is more than one provided argument, do this...
|
||||
else {
|
||||
|
||||
// Send a "too many arguments" error message using formatting with the MiniMessage API.
|
||||
Component parsed = Utilities_OG.getMM().deserialize("<#AAAAAA>[<#00AA00>Utilities<#AA0000>-OG<#AAAAAA>] <#AA0000> ERROR: Too many arguments provided. Syntax: <#FFFF55>/ping <player>");
|
||||
player.sendMessage(parsed);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Authors: christianniehaus, NotAlexNoyle.
|
||||
package me.barny1094875.utilitiesog.modules;
|
||||
|
||||
import me.barny1094875.utilitiesog.Utilities_OG;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
// Initialize command manager class.
|
||||
public class RanksModule implements CommandExecutor {
|
||||
|
||||
// Command execution event handler extending bukkit's CommandManager.
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
// Get the player object from the sender.
|
||||
Player player = (Player) sender;
|
||||
if (sender instanceof Player) {
|
||||
if (player.hasPermission("utilities.ranks")) {
|
||||
// If the player did not provide any arguments, do this...
|
||||
if (args.length == 0) {
|
||||
// Send the available ranks to the user.
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<bold><dark_purple>-=-=-=-=- <dark_green>True<dark_red>OG <aqua>Donation Store: <dark_purple>-=-=-=-=-"));
|
||||
player.sendMessage("");
|
||||
player.sendMessage("Each donor rank requires the rank before it.");
|
||||
player.sendMessage("");
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<green>Rank Overview: <dark_aqua><underlined>https://shop.true-og.net"));
|
||||
player.sendMessage("");
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<white>[OG] <gray>(<dark_green>$10 Once<gray>) <dark_aqua><underlined>https://true-og.net/og"));
|
||||
sendClickableMessage(player, "/ranks og");
|
||||
player.sendMessage("");
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<red>[OG Pro] <gray>(<dark_green>$50 Once<gray>) <dark_aqua><underlined>https://true-og.net/og-pro"));
|
||||
sendClickableMessage(player, "/ranks og-pro");
|
||||
player.sendMessage("");
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<dark_red><bold>[OG Master] <gray>(<gold>$10 Monthly<gray>) <dark_aqua><underlined>https://true-og.net/og-master"));
|
||||
sendClickableMessage(player, "/ranks og-master");
|
||||
}
|
||||
// If the player provided one or more arguments, do this...
|
||||
else if (args.length == 1) {
|
||||
// If the OG text was clicked, do this...
|
||||
if (args[0].equalsIgnoreCase("og")) {
|
||||
// Share the OG benefits with the user.
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<dark_purple><bold>-=-=-=-=- <dark_green>True<dark_red>OG <white>OG Rank: <dark_purple>-=-=-=-=-"));
|
||||
player.sendMessage("- Use /afk for an unlimited amount of time.");
|
||||
player.sendMessage("- Prominent white chat prefix");
|
||||
player.sendMessage("- Create unions with /union create.");
|
||||
player.sendMessage("- Invite people to unions with /union invite.");
|
||||
player.sendMessage("- Access to #donor-chat on Discord.");
|
||||
player.sendMessage("- 6 homes (temporary benefit until the implementation of our in-game home earning plugin).");
|
||||
player.sendMessage("- More TBA.");
|
||||
}
|
||||
// If the OG Pro text was clicked, do this...
|
||||
else if (args[0].equalsIgnoreCase("og-pro")) {
|
||||
// Share the OG Pro benefits with the user.
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<dark_purple><bold>-=-=-=-=- <dark_green>True&<dark_red>OG <red>OG Pro Rank: <dark_purple>-=-=-=-=-"));
|
||||
player.sendMessage("- All OG Benefits.");
|
||||
player.sendMessage("- Rent up to 2 shops at the player market.");
|
||||
player.sendMessage("- Special chat formatting (bold, italics, magic, etc).");
|
||||
player.sendMessage("- Use color codes in chat, mail, unions, signs, anvils, and book titles.");
|
||||
player.sendMessage("- Edit written books with /book.");
|
||||
player.sendMessage("- Edit signs with /editsign.");
|
||||
player.sendMessage("- Wear hats with /hat.");
|
||||
player.sendMessage("- Sit anywhere with /sit.");
|
||||
player.sendMessage("- Access your ender chest anywhere with /echest.");
|
||||
player.sendMessage("- Use 9 exclusive particle cosmetics with /cosmetics (up to 3 at once).");
|
||||
player.sendMessage("- More TBA.");
|
||||
}
|
||||
// If the OG Master text was clicked, do this...
|
||||
else if (args[0].equalsIgnoreCase("og-master")) {
|
||||
// Share the OG Master benefits to the user.
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<dark_purple><bold>-=-=-=-=- <dark_green>True<dark_red>OG <dark_red>OG Master Rank: <dark_purple>-=-=-=-=-"));
|
||||
player.sendMessage("- All OG and OG Pro Benefits.");
|
||||
player.sendMessage("- Rent up to 3 shops at the player market.");
|
||||
player.sendMessage("- World inspection with /co inspect.");
|
||||
player.sendMessage("- Return to last teleport destination with /back.");
|
||||
player.sendMessage("- Toggle your death coordinates in chat with /tdc.");
|
||||
player.sendMessage("- Special mail, sign, and anvil formatting (strike-through, italics, magic, etc).");
|
||||
player.sendMessage("- More TBA.");
|
||||
}
|
||||
} else {
|
||||
|
||||
// Send the player an error message if they typed too many command arguments.
|
||||
player.sendMessage(Utilities_OG.getMM().deserialize("<gray>[<dark_green>True<dark_red>OG<gray>] <red>ERROR: Too many arguments! <gold>Syntax: <yellow>/ranks"));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// Healthy exit status.
|
||||
return true;
|
||||
}
|
||||
|
||||
// Turns chat text into a command button.
|
||||
public static void sendClickableMessage(Player player, String command) {
|
||||
|
||||
// Declare a TextComponent with contents.
|
||||
TextComponent clickableText = (TextComponent) Utilities_OG.getMM().deserialize("<aqua><bold>Click here to see the benefits!");
|
||||
|
||||
// Create a click event on the chat text.
|
||||
clickableText = clickableText.clickEvent(ClickEvent.clickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||
|
||||
// Send the clickable text to the player.
|
||||
player.sendMessage(clickableText);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
# area for all of the feature enabling/disabling
|
||||
PhantomToggle: true
|
||||
EntityCrammingDisable: false
|
||||
RanksMenu: true
|
||||
Ping: true
|
||||
BuyMenu: true
|
||||
BambooWood: true
|
||||
ChainArmour: true
|
||||
ColorCodes: true
|
||||
NoFlippy: true
|
||||
|
||||
# all of the below are config used by the plugin
|
||||
# whether to disable entity cramming or not
|
||||
doEntityCramming: false
|
||||
Whitespace-only changes.
@@ -1,35 +0,0 @@
|
||||
name: Utilities-OG
|
||||
authors: [ christianniehaus, NotAlexNoyle ]
|
||||
version: '2.1.2'
|
||||
main: me.barny1094875.utilitiesog.Utilities_OG
|
||||
api-version: 1.19
|
||||
depend: [ WorldGuard ]
|
||||
commands:
|
||||
utilities:
|
||||
usage: /utilites
|
||||
togglephantoms:
|
||||
usage: /togglephantoms
|
||||
togglecramming:
|
||||
usage: /togglecramming
|
||||
ranks:
|
||||
usage: /ranks
|
||||
ping:
|
||||
usage: /ping
|
||||
bing:
|
||||
usage: /bing
|
||||
colorcodes:
|
||||
usage: /colorcodes
|
||||
|
||||
permissions:
|
||||
utilities.togglephantoms:
|
||||
description: Permission to use the /togglephantoms command.
|
||||
default: op
|
||||
utilities.togglecramming:
|
||||
description: Permission to use the /togglecramming command.
|
||||
default: op
|
||||
utilities.ranks:
|
||||
description: Permission to use the /ranks command.
|
||||
default: op
|
||||
utilities.ping:
|
||||
description: Permission to use the /ping and /bing commands.
|
||||
default: op
|
||||
@@ -1,4 +0,0 @@
|
||||
rootProject.name = "Template-OG"
|
||||
include ':libs:Utilities-OG'
|
||||
include ':libs:DiamondBank-OG'
|
||||
include ':libs:GxUI'
|
||||
@@ -0,0 +1,13 @@
|
||||
rootProject.name = "GxUI-OG"
|
||||
|
||||
ProcessBuilder("sh", "bootstrap.sh").directory(rootDir).inheritIO().start().let {
|
||||
if (it.waitFor() != 0) throw GradleException("bootstrap.sh failed")
|
||||
}
|
||||
|
||||
file("libs")
|
||||
.listFiles()
|
||||
?.filter { it.isDirectory && !it.name.startsWith(".") }
|
||||
?.forEach { dir ->
|
||||
include(":libs:${dir.name}")
|
||||
project(":libs:${dir.name}").projectDir = dir
|
||||
}
|
||||
@@ -0,0 +1,426 @@
|
||||
package net.trueog.gxui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public abstract class GUIBase implements Listener {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
private final HashMap<Integer, GUIItem> inventoryContents;
|
||||
|
||||
@Getter
|
||||
private final String inventoryName;
|
||||
|
||||
@Getter
|
||||
private final int inventorySize;
|
||||
|
||||
@Getter
|
||||
private final boolean fillEmpty;
|
||||
|
||||
@Getter
|
||||
private final Sound openSound;
|
||||
|
||||
@Getter
|
||||
private float openSoundFloat;
|
||||
|
||||
@Getter
|
||||
private final Sound errorSound;
|
||||
|
||||
@Getter
|
||||
private final float errorSoundFloat;
|
||||
|
||||
@Getter
|
||||
private final Player player;
|
||||
|
||||
@Getter
|
||||
private Inventory inventory;
|
||||
|
||||
// Prevents accidental deregistration from other GUIs that have the same name.
|
||||
private boolean isOpen = false;
|
||||
|
||||
private final HashMap<Integer, String> itemErrors;
|
||||
private final HashMap<Integer, Integer> itemTimings;
|
||||
|
||||
public GUIBase(JavaPlugin plugin, Player player, String inventoryName, int inventorySize, boolean fillEmpty) {
|
||||
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.inventoryName = inventoryName;
|
||||
this.inventorySize = inventorySize;
|
||||
this.fillEmpty = fillEmpty;
|
||||
inventoryContents = new HashMap<>();
|
||||
|
||||
openSound = null;
|
||||
|
||||
errorSound = Sound.ENTITY_ITEM_BREAK;
|
||||
errorSoundFloat = (float) 0.6;
|
||||
|
||||
itemErrors = new HashMap<>();
|
||||
itemTimings = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
public GUIBase(JavaPlugin plugin, Player player, String inventoryName, int inventorySize, boolean fillEmpty,
|
||||
Sound openSound, float openSoundFloat, Sound errorSound, float errorSoundFloat)
|
||||
{
|
||||
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.inventoryName = inventoryName;
|
||||
this.inventorySize = inventorySize;
|
||||
this.fillEmpty = fillEmpty;
|
||||
|
||||
inventoryContents = new HashMap<>();
|
||||
|
||||
this.openSound = openSound;
|
||||
this.openSoundFloat = openSoundFloat;
|
||||
|
||||
this.errorSound = errorSound;
|
||||
this.errorSoundFloat = errorSoundFloat;
|
||||
|
||||
itemErrors = new HashMap<>();
|
||||
itemTimings = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
public void open(boolean refresh) {
|
||||
|
||||
if (!isOpen) {
|
||||
|
||||
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
}
|
||||
|
||||
if (openSound != null) {
|
||||
|
||||
player.playSound(player.getLocation(), openSound, 100f, openSoundFloat);
|
||||
|
||||
}
|
||||
|
||||
isOpen = true;
|
||||
|
||||
final Inventory playersInventory = player.getInventory();
|
||||
final InventoryHolder inventoryContainer = playersInventory.getHolder(false);
|
||||
final TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize(inventoryName);
|
||||
|
||||
inventory = Bukkit.createInventory(inventoryContainer, inventorySize, nameHandler);
|
||||
|
||||
inventoryContents.clear();
|
||||
setupItems();
|
||||
|
||||
inventoryContents.entrySet().forEach(i -> inventory.setItem(i.getKey(), i.getValue().build()));
|
||||
|
||||
if (fillEmpty) {
|
||||
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
|
||||
if (inventory.getItem(i) == null) {
|
||||
|
||||
inventory.setItem(i, fillSlot());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
player.openInventory(inventory);
|
||||
|
||||
if (refresh) {
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final Inventory openInventory = ((HumanEntity) player).getOpenInventory().getTopInventory();
|
||||
if (openInventory != inventory) {
|
||||
|
||||
cancel();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
openInventory.clear();
|
||||
inventoryContents.clear();
|
||||
setupItems();
|
||||
int counter = 0;
|
||||
for (Map.Entry<Integer, GUIItem> i : inventoryContents.entrySet()) {
|
||||
|
||||
if (itemErrors.containsKey(i.getKey())) {
|
||||
|
||||
final GUIItem error = new GUIItem(Material.RED_STAINED_GLASS_PANE, 1,
|
||||
addLinebreaks(itemErrors.get(i.getKey()), 30, "&7").get(counter), "&c&lERROR");
|
||||
|
||||
counter++;
|
||||
int tick = itemTimings.get(i.getKey());
|
||||
tick++;
|
||||
|
||||
itemTimings.remove(i.getKey());
|
||||
itemTimings.put(i.getKey(), tick);
|
||||
|
||||
if (tick >= 9) {
|
||||
|
||||
itemErrors.remove(i.getKey());
|
||||
itemTimings.remove(i.getKey());
|
||||
openInventory.setItem(i.getKey(), i.getValue().build());
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
openInventory.setItem(i.getKey(), error.build());
|
||||
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
openInventory.setItem(i.getKey(), i.getValue().build());
|
||||
|
||||
}
|
||||
|
||||
if (fillEmpty) {
|
||||
|
||||
for (int i = 0; i < inventorySize; i++) {
|
||||
|
||||
if (openInventory.getItem(i) == null) {
|
||||
|
||||
openInventory.setItem(i, fillSlot());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}.runTaskTimer(plugin, 0, 5);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract void setupItems();
|
||||
|
||||
public void addItem(Integer slot, GUIItem item) {
|
||||
|
||||
inventoryContents.put(slot, item);
|
||||
|
||||
}
|
||||
|
||||
private ItemStack fillSlot() {
|
||||
|
||||
final ItemStack i = new ItemStack(Material.GRAY_STAINED_GLASS_PANE, 1);
|
||||
final ItemMeta m = i.getItemMeta();
|
||||
final TextComponent emptySlotDisplayName = LegacyComponentSerializer.legacyAmpersand().deserialize(" ");
|
||||
|
||||
m.displayName(emptySlotDisplayName);
|
||||
i.setItemMeta(m);
|
||||
|
||||
return i;
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDrop(PlayerDropItemEvent event) {
|
||||
|
||||
if (event.getItemDrop().getItemStack().getItemMeta().isUnbreakable()) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void inventoryDragHandler(InventoryDragEvent event) {
|
||||
|
||||
if (event.getCursor().getItemMeta().isUnbreakable()) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void playerInventoryClickHandler(InventoryClickEvent event) {
|
||||
|
||||
final Player clickedPlayer = (Player) event.getWhoClicked();
|
||||
final ClickType clickType = event.getClick();
|
||||
final Inventory clickedInventory = event.getClickedInventory();
|
||||
final ItemStack item = event.getCurrentItem();
|
||||
final Inventory topInventory = event.getView().getTopInventory();
|
||||
if (clickedPlayer != player) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (clickedInventory == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (topInventory != inventory) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
// Prevent taking or moving placeholders/GUI items from this GUI.
|
||||
if (event.getRawSlot() < topInventory.getSize()) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
if (item == null || !item.hasItemMeta()) {
|
||||
|
||||
if (errorSound != null) {
|
||||
|
||||
player.playSound(player.getLocation(), errorSound, 50f, errorSoundFloat);
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (itemErrors.containsKey(event.getSlot())) {
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 50f, 0.7f);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (inventoryContents.containsKey(event.getSlot())) {
|
||||
|
||||
final GUIItem guiItem = inventoryContents.get(event.getSlot());
|
||||
if (!guiItem.isButton()) {
|
||||
|
||||
if (guiItem.isPlayErrorSound() && errorSound != null) {
|
||||
|
||||
player.playSound(player.getLocation(), errorSound, 50f, errorSoundFloat);
|
||||
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final boolean exec = guiItem.executeClick(clickType);
|
||||
final boolean condition = !exec && guiItem.isPlayErrorSound() && errorSound != null;
|
||||
if (condition) {
|
||||
|
||||
player.playSound(player.getLocation(), errorSound, 100f, errorSoundFloat);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (event.isShiftClick()) {
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void close(InventoryCloseEvent event) {
|
||||
|
||||
final Player closer = (Player) event.getPlayer();
|
||||
final boolean condition = event.getInventory() == inventory && isOpen && closer == player;
|
||||
if (!condition) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
HandlerList.unregisterAll(this);
|
||||
|
||||
isOpen = false;
|
||||
|
||||
}
|
||||
|
||||
public void showErrorItem(Player player, Integer item, String error, boolean sound) {
|
||||
|
||||
itemErrors.put(item, error);
|
||||
itemTimings.put(item, 0);
|
||||
|
||||
if (sound) {
|
||||
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 100f, 0.7f);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public ArrayList<String> addLinebreaks(String input, int maxLineLength, String toAppendAfterNewline) {
|
||||
|
||||
final ArrayList<String> result = new ArrayList<>();
|
||||
final StringTokenizer tok = new StringTokenizer(input, " ");
|
||||
StringBuilder output = new StringBuilder();
|
||||
|
||||
output.insert(0, toAppendAfterNewline);
|
||||
int lineLen = 0;
|
||||
while (tok.hasMoreTokens()) {
|
||||
|
||||
final String word = tok.nextToken();
|
||||
|
||||
if (lineLen + word.length() > maxLineLength) {
|
||||
|
||||
result.add(output.toString());
|
||||
output = new StringBuilder();
|
||||
output.append(toAppendAfterNewline);
|
||||
lineLen = 0;
|
||||
|
||||
}
|
||||
|
||||
output.append(word).append(" ");
|
||||
lineLen += word.length();
|
||||
|
||||
}
|
||||
|
||||
result.add(output.toString());
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package net.trueog.gxui;
|
||||
|
||||
public abstract interface GUIButton {
|
||||
|
||||
abstract boolean leftClick();
|
||||
|
||||
abstract boolean leftClickShift();
|
||||
|
||||
abstract boolean rightClick();
|
||||
|
||||
abstract boolean rightClickShift();
|
||||
|
||||
}
|
||||
+155
-51
@@ -1,9 +1,8 @@
|
||||
package uk.hotten.gxui;
|
||||
package net.trueog.gxui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@@ -22,136 +21,241 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
@Accessors(fluent = true)
|
||||
public class GUIItem {
|
||||
|
||||
@Getter @Setter private Material item;
|
||||
@Getter @Setter private int amount;
|
||||
@Getter @Setter private String displayName;
|
||||
@Getter @Setter private ArrayList<String> lore;
|
||||
@Getter
|
||||
@Setter
|
||||
private Material item;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private int amount;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private String displayName;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private List<TextComponent> lore;
|
||||
|
||||
private boolean isSkull;
|
||||
private String skullOwner;
|
||||
|
||||
private HashMap<Enchantment, Integer> enchantments = new HashMap<>();
|
||||
@Getter @Setter private boolean unbreakable = false;
|
||||
|
||||
@Getter @Setter private GUIButton button;
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean unbreakable = false;
|
||||
|
||||
@Getter @Setter private short type;
|
||||
@Getter
|
||||
@Setter
|
||||
private GUIButton button;
|
||||
|
||||
@Getter @Setter private boolean playErrorSound;
|
||||
@Getter
|
||||
@Setter
|
||||
private short type;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean playErrorSound;
|
||||
|
||||
public GUIItem() {
|
||||
|
||||
item = Material.AIR;
|
||||
amount = 1;
|
||||
displayName = "Not Set";
|
||||
lore = new ArrayList<>();
|
||||
type = -1;
|
||||
playErrorSound = true;
|
||||
|
||||
}
|
||||
|
||||
public GUIItem(Material item) {
|
||||
|
||||
this.item = item;
|
||||
|
||||
amount = 1;
|
||||
displayName = "Not Set";
|
||||
lore = new ArrayList<>();
|
||||
type = -1;
|
||||
playErrorSound = true;
|
||||
|
||||
}
|
||||
|
||||
public GUIItem(Material item, int amount, String displayName) {
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
this.displayName = displayName;
|
||||
public GUIItem(GUIButton guibutton) {
|
||||
|
||||
amount = 1;
|
||||
displayName = "Not Set";
|
||||
lore = new ArrayList<>();
|
||||
type = -1;
|
||||
playErrorSound = true;
|
||||
|
||||
}
|
||||
|
||||
public GUIItem(Material item, int amount, String displayName) {
|
||||
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
this.displayName = displayName;
|
||||
|
||||
lore = new ArrayList<>();
|
||||
type = -1;
|
||||
playErrorSound = true;
|
||||
|
||||
}
|
||||
|
||||
public GUIItem(Material item, int amount, String displayName, String skullOwner) {
|
||||
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
this.displayName = displayName;
|
||||
this.skullOwner = skullOwner;
|
||||
|
||||
isSkull = true;
|
||||
lore = new ArrayList<>();
|
||||
type = -1;
|
||||
playErrorSound = true;
|
||||
|
||||
}
|
||||
|
||||
public GUIItem(Material item, int amount, GUIButton button, String displayName, String skullOwner) {
|
||||
|
||||
this.item = item;
|
||||
this.amount = amount;
|
||||
this.button = button;
|
||||
this.displayName = displayName;
|
||||
this.skullOwner = skullOwner;
|
||||
|
||||
isSkull = true;
|
||||
lore = new ArrayList<>();
|
||||
type = -1;
|
||||
playErrorSound = true;
|
||||
|
||||
}
|
||||
|
||||
public GUIButton getButton() {
|
||||
|
||||
return button;
|
||||
|
||||
}
|
||||
|
||||
public void setButton(GUIButton button) {
|
||||
|
||||
this.button = button;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ItemStack
|
||||
*/
|
||||
public ItemStack build() {
|
||||
ItemStack i;
|
||||
TextComponent displayNameTextComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(displayName);
|
||||
List<TextComponent> loreTextComponent = GUIBase.convertToTextComponents(lore);
|
||||
|
||||
final ItemStack i;
|
||||
final TextComponent displayNameTextComponent = LegacyComponentSerializer.legacyAmpersand()
|
||||
.deserialize(displayName);
|
||||
final List<TextComponent> loreTextComponent = lore;
|
||||
try {
|
||||
if (! isSkull) {
|
||||
if (type != -1)
|
||||
i = new ItemStack(item, amount); // TODO: shorts?
|
||||
else
|
||||
i = new ItemStack(item, amount);
|
||||
ItemMeta m = i.getItemMeta();
|
||||
if (! displayName.equals("Not Set"))
|
||||
|
||||
if (!isSkull) {
|
||||
|
||||
i = type != -1 ? new ItemStack(item, amount) : new ItemStack(item, amount);
|
||||
|
||||
final ItemMeta m = i.getItemMeta();
|
||||
if (!"Not Set".equals(displayName)) {
|
||||
|
||||
m.displayName(displayNameTextComponent);
|
||||
|
||||
}
|
||||
|
||||
m.lore(loreTextComponent);
|
||||
if (!enchantments.isEmpty())
|
||||
for (Map.Entry<Enchantment, Integer> e : enchantments.entrySet())
|
||||
m.addEnchant(e.getKey(), e.getValue(), true);
|
||||
|
||||
if (!enchantments.isEmpty()) {
|
||||
|
||||
enchantments.entrySet().forEach(e -> m.addEnchant(e.getKey(), e.getValue(), true));
|
||||
|
||||
}
|
||||
|
||||
i.setItemMeta(m);
|
||||
|
||||
} else {
|
||||
|
||||
i = new ItemStack(item, amount);
|
||||
SkullMeta m = (SkullMeta) i.getItemMeta();
|
||||
final SkullMeta m = (SkullMeta) i.getItemMeta();
|
||||
|
||||
m.setOwningPlayer(Bukkit.getOfflinePlayer(skullOwner));
|
||||
if (!displayName.equals("Not Set"))
|
||||
|
||||
if (!"Not Set".equals(displayName)) {
|
||||
|
||||
m.displayName(displayNameTextComponent);
|
||||
|
||||
}
|
||||
|
||||
i.setUnbreakable(unbreakable);
|
||||
m.lore(loreTextComponent);
|
||||
i.setItemMeta(m);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
||||
} catch (Exception error) {
|
||||
|
||||
error.printStackTrace();
|
||||
|
||||
return new ItemStack(Material.DIRT);
|
||||
|
||||
}
|
||||
|
||||
return i;
|
||||
|
||||
}
|
||||
|
||||
public boolean isPlayErrorSound() {
|
||||
return playErrorSound;
|
||||
}
|
||||
|
||||
public void setPlayErrorSound(boolean playErrorSound) {
|
||||
this.playErrorSound = playErrorSound;
|
||||
}
|
||||
return playErrorSound;
|
||||
|
||||
}
|
||||
|
||||
public void setPlayErrorSound(boolean playErrorSound) {
|
||||
|
||||
this.playErrorSound = playErrorSound;
|
||||
|
||||
}
|
||||
|
||||
public boolean isButton() {
|
||||
|
||||
public boolean isButton() {
|
||||
return !(button == null);
|
||||
|
||||
}
|
||||
|
||||
public boolean executeClick(ClickType clickType) {
|
||||
switch (clickType) {
|
||||
case LEFT:
|
||||
return button.leftClick();
|
||||
case SHIFT_LEFT:
|
||||
return button.leftClickShift();
|
||||
case RIGHT:
|
||||
return button.rightClick();
|
||||
case SHIFT_RIGHT:
|
||||
return button.rightClickShift();
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
return switch (clickType) {
|
||||
|
||||
case LEFT -> button.leftClick();
|
||||
case SHIFT_LEFT -> button.leftClickShift();
|
||||
case RIGHT -> button.rightClick();
|
||||
case SHIFT_RIGHT -> button.rightClickShift();
|
||||
default -> false;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
public GUIItem enchantment(Enchantment ench, Integer level) {
|
||||
if (enchantments == null)
|
||||
|
||||
if (enchantments == null) {
|
||||
|
||||
enchantments = new HashMap<>();
|
||||
|
||||
}
|
||||
|
||||
enchantments.put(ench, level);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public GUIItem duplicateByConstructor() {
|
||||
|
||||
return new GUIItem(item, amount, displayName);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,748 @@
|
||||
package net.trueog.gxui.progress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.trueog.gxui.GUIBase;
|
||||
import net.trueog.gxui.GUIButton;
|
||||
import net.trueog.gxui.GUIItem;
|
||||
|
||||
// A layered inventory for groups of material-backed goals. Goals are read-only; a
|
||||
// section may expose one clickable action button on its detail view.
|
||||
public final class ProgressMenu extends GUIBase {
|
||||
|
||||
public static final int INVENTORY_SIZE = 54;
|
||||
public static final int CONTENT_PER_PAGE = 45;
|
||||
public static final int BACK_SLOT = 45;
|
||||
public static final int PREVIOUS_PAGE_SLOT = 47;
|
||||
public static final int CLOSE_SLOT = 49;
|
||||
public static final int NEXT_PAGE_SLOT = 51;
|
||||
public static final int ACTION_SLOT = 52;
|
||||
public static final int INFORMATION_SLOT = 53;
|
||||
|
||||
// How long the action slot shows an error before the action button returns.
|
||||
private static final long ACTION_ERROR_TICKS = 40L;
|
||||
|
||||
private static final List<Integer> CONTENT_SLOTS = createContentSlots();
|
||||
private static final LegacyComponentSerializer LEGACY = LegacyComponentSerializer.legacyAmpersand();
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final String baseTitle;
|
||||
private final List<Section> sections;
|
||||
private final int sectionIndex;
|
||||
private final int page;
|
||||
|
||||
// True while the action slot displays an error item; clicks on it are ignored.
|
||||
private boolean actionErrorActive = false;
|
||||
|
||||
private ProgressMenu(JavaPlugin plugin, Player player, String baseTitle, List<Section> sections, int sectionIndex,
|
||||
int page)
|
||||
{
|
||||
|
||||
super(plugin, player, buildInventoryName(baseTitle, sections, sectionIndex, page), INVENTORY_SIZE, true);
|
||||
|
||||
this.plugin = plugin;
|
||||
this.baseTitle = baseTitle;
|
||||
this.sections = sections;
|
||||
this.sectionIndex = normalizeSectionIndex(sectionIndex, sections.size());
|
||||
this.page = normalizePage(page, getTotalPages(getVisibleItemCount(sections, this.sectionIndex)));
|
||||
|
||||
}
|
||||
|
||||
public static Builder builder(JavaPlugin plugin, Player player, String inventoryName) {
|
||||
|
||||
return new Builder(plugin, player, inventoryName);
|
||||
|
||||
}
|
||||
|
||||
// true when this menu is displaying one section's goals.
|
||||
public boolean isDetailView() {
|
||||
|
||||
return sectionIndex >= 0;
|
||||
|
||||
}
|
||||
|
||||
// Get the numeric page number (0 index).
|
||||
public int getPage() {
|
||||
|
||||
return page;
|
||||
|
||||
}
|
||||
|
||||
public int getTotalPages() {
|
||||
|
||||
return getTotalPages(getVisibleItemCount(sections, sectionIndex));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupItems() {
|
||||
|
||||
if (isDetailView()) {
|
||||
|
||||
setupDetailItems();
|
||||
|
||||
} else {
|
||||
|
||||
setupIndexItems();
|
||||
|
||||
}
|
||||
|
||||
setupNavigationItems();
|
||||
|
||||
}
|
||||
|
||||
private void setupIndexItems() {
|
||||
|
||||
final int firstSection = page * CONTENT_PER_PAGE;
|
||||
final int lastSection = Math.min(firstSection + CONTENT_PER_PAGE, sections.size());
|
||||
for (int currentSection = firstSection; currentSection < lastSection; currentSection++) {
|
||||
|
||||
final int pageIndex = currentSection - firstSection;
|
||||
|
||||
addItem(CONTENT_SLOTS.get(pageIndex), buildSectionItem(currentSection));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setupDetailItems() {
|
||||
|
||||
final Section section = sections.get(sectionIndex);
|
||||
final List<Goal> goals = section.goals();
|
||||
final int firstGoal = page * CONTENT_PER_PAGE;
|
||||
final int lastGoal = Math.min(firstGoal + CONTENT_PER_PAGE, goals.size());
|
||||
for (int currentGoal = firstGoal; currentGoal < lastGoal; currentGoal++) {
|
||||
|
||||
final int pageIndex = currentGoal - firstGoal;
|
||||
addItem(CONTENT_SLOTS.get(pageIndex), buildGoalItem(goals.get(currentGoal)));
|
||||
|
||||
}
|
||||
|
||||
if (!section.description().isEmpty()) {
|
||||
|
||||
addItem(INFORMATION_SLOT, buildInformationItem(section));
|
||||
|
||||
}
|
||||
|
||||
if (section.action() != null) {
|
||||
|
||||
addItem(ACTION_SLOT, buildActionItem(section.action()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Temporarily replace this detail view's action button with an error item.
|
||||
// Main thread only; a no-op once the menu is closed.
|
||||
public void showActionError(String message) {
|
||||
|
||||
Objects.requireNonNull(message, "message");
|
||||
|
||||
if (!isDetailView()) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
final Action action = sections.get(sectionIndex).action();
|
||||
final Inventory inventory = getInventory();
|
||||
if (action == null || inventory == null || !isViewing(inventory)) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
actionErrorActive = true;
|
||||
|
||||
final GUIItem errorItem = new GUIItem(Material.RED_STAINED_GLASS_PANE, 1, "&c&lError");
|
||||
errorItem.lore(toLoreComponents(addLinebreaks(message, 30, "&7")));
|
||||
inventory.setItem(ACTION_SLOT, errorItem.build());
|
||||
playActionErrorSound();
|
||||
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
||||
|
||||
actionErrorActive = false;
|
||||
|
||||
if (isViewing(inventory)) {
|
||||
|
||||
inventory.setItem(ACTION_SLOT, buildActionItem(action).build());
|
||||
|
||||
}
|
||||
|
||||
}, ACTION_ERROR_TICKS);
|
||||
|
||||
}
|
||||
|
||||
private boolean isViewing(Inventory inventory) {
|
||||
|
||||
return getPlayer().getOpenInventory().getTopInventory() == inventory;
|
||||
|
||||
}
|
||||
|
||||
private void playActionErrorSound() {
|
||||
|
||||
getPlayer().playSound(getPlayer().getLocation(), Sound.BLOCK_NOTE_BLOCK_BASS, 100f, 0.7f);
|
||||
|
||||
}
|
||||
|
||||
private void setupNavigationItems() {
|
||||
|
||||
if (isDetailView()) {
|
||||
|
||||
addItem(BACK_SLOT, buildBackButton());
|
||||
|
||||
}
|
||||
|
||||
if (page > 0) {
|
||||
|
||||
addItem(PREVIOUS_PAGE_SLOT, buildPageButton("&ePrevious Page", page - 1));
|
||||
|
||||
}
|
||||
|
||||
addItem(CLOSE_SLOT, buildCloseButton());
|
||||
|
||||
if (page + 1 < getTotalPages()) {
|
||||
|
||||
addItem(NEXT_PAGE_SLOT, buildPageButton("&eNext Page", page + 1));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildSectionItem(int targetSection) {
|
||||
|
||||
final Section section = sections.get(targetSection);
|
||||
final State state = section.state();
|
||||
final GUIItem guiItem = new GUIItem(state.getMaterial(), 1, state.getColor() + section.name());
|
||||
|
||||
final List<String> lore = new ArrayList<>();
|
||||
lore.add(state.getStatusLine());
|
||||
|
||||
if (!section.description().isEmpty()) {
|
||||
|
||||
lore.add("");
|
||||
lore.addAll(section.description());
|
||||
|
||||
}
|
||||
|
||||
lore.add("");
|
||||
lore.add("&eClick to view requirements.");
|
||||
|
||||
guiItem.lore(toLoreComponents(lore));
|
||||
guiItem.playErrorSound(false);
|
||||
guiItem.button(createButton(() -> openSection(targetSection, 0)));
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildGoalItem(Goal goal) {
|
||||
|
||||
final String color = goal.complete() ? "&a" : "&c";
|
||||
final GUIItem guiItem = new GUIItem(goal.material(), 1, color + goal.name());
|
||||
|
||||
final List<String> lore = new ArrayList<>();
|
||||
lore.add(goal.complete() ? "&aCompleted" : "&cIncomplete");
|
||||
lore.add("");
|
||||
|
||||
if (goal.hasProgress()) {
|
||||
|
||||
lore.add("&7Progress: &f" + goal.current() + "&7/&f" + goal.target());
|
||||
|
||||
} else {
|
||||
|
||||
lore.add("&7Status: &f" + (goal.complete() ? "Complete" : "Incomplete"));
|
||||
|
||||
}
|
||||
|
||||
guiItem.lore(toLoreComponents(lore));
|
||||
guiItem.playErrorSound(false);
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildInformationItem(Section section) {
|
||||
|
||||
final GUIItem guiItem = new GUIItem(Material.PAPER, 1, "&eInformation");
|
||||
|
||||
guiItem.lore(toLoreComponents(section.description()));
|
||||
guiItem.playErrorSound(false);
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildActionItem(Action action) {
|
||||
|
||||
final GUIItem guiItem = new GUIItem(action.material(), 1, action.name());
|
||||
|
||||
guiItem.lore(toLoreComponents(action.lore()));
|
||||
guiItem.playErrorSound(false);
|
||||
guiItem.button(createButton(() -> {
|
||||
|
||||
if (actionErrorActive) {
|
||||
|
||||
playActionErrorSound();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
action.handler().accept(this, getPlayer());
|
||||
|
||||
}));
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildBackButton() {
|
||||
|
||||
final GUIItem guiItem = new GUIItem(Material.ARROW, 1, "&eBack to Menu");
|
||||
|
||||
guiItem.playErrorSound(false);
|
||||
guiItem.button(createButton(() -> openIndex(getIndexPage(sectionIndex))));
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildCloseButton() {
|
||||
|
||||
final GUIItem guiItem = new GUIItem(Material.BARRIER, 1, "&cClose");
|
||||
|
||||
guiItem.playErrorSound(false);
|
||||
guiItem.button(createButton(() -> getPlayer().closeInventory()));
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private GUIItem buildPageButton(String displayName, int targetPage) {
|
||||
|
||||
final GUIItem guiItem = new GUIItem(Material.ARROW, 1, displayName);
|
||||
|
||||
guiItem.lore(toLoreComponents(List.of("&7Page " + (targetPage + 1) + " of " + getTotalPages())));
|
||||
guiItem.playErrorSound(false);
|
||||
guiItem.button(createButton(() -> openCurrentLayer(targetPage)));
|
||||
|
||||
return guiItem;
|
||||
|
||||
}
|
||||
|
||||
private void openCurrentLayer(int targetPage) {
|
||||
|
||||
if (isDetailView()) {
|
||||
|
||||
openSection(sectionIndex, targetPage);
|
||||
|
||||
} else {
|
||||
|
||||
openIndex(targetPage);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void openIndex(int targetPage) {
|
||||
|
||||
new ProgressMenu(plugin, getPlayer(), baseTitle, sections, -1, targetPage).open(false);
|
||||
|
||||
}
|
||||
|
||||
private void openSection(int targetSection, int targetPage) {
|
||||
|
||||
new ProgressMenu(plugin, getPlayer(), baseTitle, sections, targetSection, targetPage).open(false);
|
||||
|
||||
}
|
||||
|
||||
private GUIButton createButton(Runnable clickHandler) {
|
||||
|
||||
return new GUIButton() {
|
||||
|
||||
@Override
|
||||
public boolean leftClick() {
|
||||
|
||||
return handleClick();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leftClickShift() {
|
||||
|
||||
return handleClick();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rightClick() {
|
||||
|
||||
return handleClick();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean rightClickShift() {
|
||||
|
||||
return handleClick();
|
||||
|
||||
}
|
||||
|
||||
private boolean handleClick() {
|
||||
|
||||
clickHandler.run();
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
private static List<TextComponent> toLoreComponents(List<String> lore) {
|
||||
|
||||
return lore.stream().map(ProgressMenu::toTextComponent).toList();
|
||||
|
||||
}
|
||||
|
||||
private static TextComponent toTextComponent(String line) {
|
||||
|
||||
final Component component = LEGACY.deserialize(line);
|
||||
|
||||
return (TextComponent) component;
|
||||
|
||||
}
|
||||
|
||||
private static String buildInventoryName(String baseTitle, List<Section> sections, int sectionIndex, int page) {
|
||||
|
||||
Objects.requireNonNull(baseTitle, "baseTitle");
|
||||
Objects.requireNonNull(sections, "sections");
|
||||
final int normalizedSection = normalizeSectionIndex(sectionIndex, sections.size());
|
||||
final String title = normalizedSection < 0 ? baseTitle : sections.get(normalizedSection).name();
|
||||
final int itemCount = getVisibleItemCount(sections, normalizedSection);
|
||||
final int totalPages = getTotalPages(itemCount);
|
||||
if (totalPages == 1) {
|
||||
|
||||
return title;
|
||||
|
||||
}
|
||||
|
||||
final int normalizedPage = normalizePage(page, totalPages);
|
||||
return title + " &7(" + (normalizedPage + 1) + "/" + totalPages + ")";
|
||||
|
||||
}
|
||||
|
||||
private static int getVisibleItemCount(List<Section> sections, int sectionIndex) {
|
||||
|
||||
return sectionIndex < 0 ? sections.size() : sections.get(sectionIndex).goals().size();
|
||||
|
||||
}
|
||||
|
||||
private static int getTotalPages(int itemCount) {
|
||||
|
||||
return Math.max(1, (int) Math.ceil((double) itemCount / CONTENT_PER_PAGE));
|
||||
|
||||
}
|
||||
|
||||
private static int normalizePage(int page, int totalPages) {
|
||||
|
||||
if (page < 0) {
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
return page >= totalPages ? totalPages - 1 : page;
|
||||
|
||||
}
|
||||
|
||||
private static int normalizeSectionIndex(int sectionIndex, int sectionCount) {
|
||||
|
||||
return sectionIndex >= 0 && sectionIndex < sectionCount ? sectionIndex : -1;
|
||||
|
||||
}
|
||||
|
||||
private static int getIndexPage(int sectionIndex) {
|
||||
|
||||
return sectionIndex / CONTENT_PER_PAGE;
|
||||
|
||||
}
|
||||
|
||||
private static List<Integer> createContentSlots() {
|
||||
|
||||
final List<Integer> slots = new ArrayList<>(CONTENT_PER_PAGE);
|
||||
for (int row = 0; row < 5; row++) {
|
||||
|
||||
for (int column = 0; column < 9; column++) {
|
||||
|
||||
slots.add(row * 9 + column);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return Collections.unmodifiableList(slots);
|
||||
|
||||
}
|
||||
|
||||
// Section state and its fixed first-layer wool material.
|
||||
public enum State {
|
||||
|
||||
NOT_STARTED(Material.RED_WOOL, "&c", "&cNot Started"), IN_PROGRESS(Material.YELLOW_WOOL, "&e", "&eIn Progress"),
|
||||
COMPLETE(Material.LIME_WOOL, "&a", "&aCompleted");
|
||||
|
||||
private final Material material;
|
||||
private final String color;
|
||||
private final String statusLine;
|
||||
|
||||
State(Material material, String color, String statusLine) {
|
||||
|
||||
this.material = material;
|
||||
this.color = color;
|
||||
this.statusLine = statusLine;
|
||||
|
||||
}
|
||||
|
||||
private Material getMaterial() {
|
||||
|
||||
return material;
|
||||
|
||||
}
|
||||
|
||||
private String getColor() {
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
private String getStatusLine() {
|
||||
|
||||
return statusLine;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private record Goal(Material material, String name, boolean complete, long current, long target,
|
||||
boolean hasProgress)
|
||||
{
|
||||
|
||||
private Goal(Material material, String name, boolean complete) {
|
||||
|
||||
this(material, name, complete, 0L, 0L, false);
|
||||
|
||||
}
|
||||
|
||||
private Goal(Material material, String name, long current, long target) {
|
||||
|
||||
this(material, name, current >= target, current, target, true);
|
||||
|
||||
}
|
||||
|
||||
private Goal {
|
||||
|
||||
Objects.requireNonNull(material, "material");
|
||||
Objects.requireNonNull(name, "name");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// A clickable button shown at ACTION_SLOT on a section's detail view.
|
||||
private record Action(Material material, String name, List<String> lore, BiConsumer<ProgressMenu, Player> handler) {
|
||||
|
||||
private Action {
|
||||
|
||||
Objects.requireNonNull(material, "material");
|
||||
Objects.requireNonNull(name, "name");
|
||||
Objects.requireNonNull(handler, "handler");
|
||||
|
||||
lore = List.copyOf(Objects.requireNonNull(lore, "lore"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// action is null when the section has no button.
|
||||
private record Section(String name, State state, List<Goal> goals, List<String> description, Action action) {
|
||||
|
||||
private Section {
|
||||
|
||||
Objects.requireNonNull(name, "name");
|
||||
Objects.requireNonNull(state, "state");
|
||||
|
||||
goals = List.copyOf(Objects.requireNonNull(goals, "goals"));
|
||||
description = List.copyOf(Objects.requireNonNull(description, "description"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Builder for layered ProgressMenu.
|
||||
public static final class Builder {
|
||||
|
||||
private final JavaPlugin plugin;
|
||||
private final Player player;
|
||||
private final String title;
|
||||
private final List<Section> sections = new ArrayList<>();
|
||||
|
||||
private String pendingName;
|
||||
private State pendingState;
|
||||
private List<Goal> pendingGoals;
|
||||
private List<String> pendingDescription;
|
||||
private Action pendingAction;
|
||||
|
||||
private Builder(JavaPlugin plugin, Player player, String title) {
|
||||
|
||||
this.plugin = Objects.requireNonNull(plugin, "plugin");
|
||||
this.player = Objects.requireNonNull(player, "player");
|
||||
this.title = Objects.requireNonNull(title, "title");
|
||||
|
||||
}
|
||||
|
||||
// Start a section. Its first-layer item is always the state's color of wool
|
||||
// (red, yellow, green).
|
||||
public Builder section(String name, State state) {
|
||||
|
||||
flushPending();
|
||||
|
||||
pendingName = Objects.requireNonNull(name, "name");
|
||||
pendingState = Objects.requireNonNull(state, "state");
|
||||
pendingGoals = new ArrayList<>();
|
||||
pendingDescription = new ArrayList<>();
|
||||
pendingAction = null;
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// A counter for which completion is derived from current >= target.
|
||||
public Builder progress(Material material, String name, long current, long target) {
|
||||
|
||||
requirePending();
|
||||
|
||||
pendingGoals.add(new Goal(material, name, current, target));
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public Builder goal(Material material, String name, boolean complete) {
|
||||
|
||||
requirePending();
|
||||
|
||||
pendingGoals.add(new Goal(material, name, complete));
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public Builder description(String... lines) {
|
||||
|
||||
requirePending();
|
||||
|
||||
Collections.addAll(pendingDescription, lines);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
// Give the current section one clickable button at ACTION_SLOT of its detail
|
||||
// view; calling it again replaces the button. The handler receives the clicked
|
||||
// menu instance so it can call showActionError.
|
||||
public Builder action(Material material, String name, List<String> lore,
|
||||
BiConsumer<ProgressMenu, Player> handler)
|
||||
{
|
||||
|
||||
requirePending();
|
||||
|
||||
pendingAction = new Action(material, name, lore, handler);
|
||||
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
public Builder action(Material material, String name, List<String> lore, Consumer<Player> handler) {
|
||||
|
||||
Objects.requireNonNull(handler, "handler");
|
||||
|
||||
return action(material, name, lore, (menu, clicker) -> handler.accept(clicker));
|
||||
|
||||
}
|
||||
|
||||
// Open the first-layer section.
|
||||
public ProgressMenu open() {
|
||||
|
||||
flushPending();
|
||||
|
||||
return openAt(-1);
|
||||
|
||||
}
|
||||
|
||||
// Open straight into one section's detail view (0-indexed, in the order the
|
||||
// sections were added). Out-of-range indexes fall back to the first layer.
|
||||
public ProgressMenu openSection(int sectionIndex) {
|
||||
|
||||
flushPending();
|
||||
|
||||
return openAt(sectionIndex);
|
||||
|
||||
}
|
||||
|
||||
private ProgressMenu openAt(int sectionIndex) {
|
||||
|
||||
final ProgressMenu menu = new ProgressMenu(plugin, player, title, List.copyOf(sections), sectionIndex, 0);
|
||||
menu.open(false);
|
||||
|
||||
return menu;
|
||||
|
||||
}
|
||||
|
||||
private void requirePending() {
|
||||
|
||||
if (pendingName == null) {
|
||||
|
||||
throw new IllegalStateException("Call section(name, state) before adding goals or descriptions");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void flushPending() {
|
||||
|
||||
if (pendingName == null) {
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
sections.add(new Section(pendingName, pendingState, pendingGoals, pendingDescription, pendingAction));
|
||||
|
||||
pendingName = null;
|
||||
pendingState = null;
|
||||
pendingGoals = null;
|
||||
pendingDescription = null;
|
||||
pendingAction = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Author: NotAlexNoyle.
|
||||
package plugin;
|
||||
|
||||
// Import libraries.
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
|
||||
// Hook into Bukkit's Listener.
|
||||
public class Listeners implements Listener {
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
|
||||
// Utilities_OG utilities = (Utilities_OG) Bukkit.getPluginManager().getPlugin("Utilities-OG");
|
||||
new SpectatorGui(TemplateOG.getPlugin(), event.getPlayer()).open(true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
package plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import uk.hotten.gxui.GUIBase;
|
||||
import uk.hotten.gxui.GUIButton;
|
||||
import uk.hotten.gxui.GUIItem;
|
||||
|
||||
public class SpectatorGui extends GUIBase {
|
||||
|
||||
private Player assignedPlayer;
|
||||
|
||||
public SpectatorGui(JavaPlugin plugin, Player player) {
|
||||
super(plugin, player, "&3&lTest GUI", 9, true);
|
||||
assignedPlayer = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setupItems() {
|
||||
int curr = 0;
|
||||
GUIItem item = null;
|
||||
List<String> name = new ArrayList<String>(18);
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
// Add a new element to the list for each player.
|
||||
name.add("&eTeleport to: &d&l" + p.getName());
|
||||
}
|
||||
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
||||
item = new GUIItem(Material.PLAYER_HEAD, 1, name.get(curr), p.getName());
|
||||
GUIButton button = new GUIButton() {
|
||||
@Override
|
||||
public boolean leftClick() {
|
||||
assignedPlayer.closeInventory();
|
||||
assignedPlayer.teleport(p);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public boolean leftClickShift() { return false; }
|
||||
@Override public boolean rightClick() { return false; }
|
||||
@Override public boolean rightClickShift() { return false; }
|
||||
|
||||
};
|
||||
|
||||
item.button(button);
|
||||
|
||||
addItem(curr, item);
|
||||
curr = nextCurr(curr);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int nextCurr(int curr) {
|
||||
if (curr == 3)
|
||||
return 6;
|
||||
else
|
||||
return (curr += 1);
|
||||
}
|
||||
|
||||
public static ArrayList<TextComponent> convertToTextComponents(List<String> stringList) {
|
||||
ArrayList<TextComponent> textComponents = new ArrayList<TextComponent>(18);
|
||||
|
||||
for (String str : stringList) {
|
||||
TextComponent textComponent = LegacyComponentSerializer.legacyAmpersand().deserialize(str);
|
||||
textComponents.add(textComponent);
|
||||
}
|
||||
|
||||
return textComponents;
|
||||
}
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
// This is free and unencumbered software released into the public domain.
|
||||
// Author: NotAlexNoyle.
|
||||
|
||||
package plugin;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import io.github.miniplaceholders.api.Expansion;
|
||||
import io.github.miniplaceholders.api.MiniPlaceholders;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.minimessage.tag.Tag;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.trueog.diamondbankog.DiamondBankOG;
|
||||
import net.trueog.diamondbankog.PostgreSQL.BalanceType;
|
||||
|
||||
// Extending this class is standard bukkit boilerplate for any plugin, or else the server software won't load the classes.
|
||||
public class TemplateOG extends JavaPlugin {
|
||||
|
||||
private static TemplateOG plugin;
|
||||
|
||||
// What to do when the plugin is run by the server.
|
||||
public void onEnable() {
|
||||
|
||||
// Register the plugin instance.
|
||||
plugin = this;
|
||||
|
||||
// Register the event.
|
||||
getServer().getPluginManager().registerEvents(new Listeners(), this);
|
||||
|
||||
// Register the placeholder.
|
||||
registerExpansion();
|
||||
|
||||
}
|
||||
|
||||
public static TemplateOG getPlugin() {
|
||||
|
||||
// Pass instance of main to other classes.
|
||||
return plugin;
|
||||
|
||||
}
|
||||
|
||||
public void registerExpansion() {
|
||||
Expansion.Builder builder = Expansion.builder("diamondbank_og_balance");
|
||||
builder.filter(Player.class);
|
||||
|
||||
builder.audiencePlaceholder("name", (audience, ctx, queue) -> {
|
||||
final Player player = (Player) audience;
|
||||
Utils.diamondBankOGPlaceholderMessage(player, "&BYour balance is: " + checkPlayerBalance(player));
|
||||
TextComponent nameHandler = LegacyComponentSerializer.legacyAmpersand().deserialize(player.getName());
|
||||
return Tag.selfClosingInserting(nameHandler);
|
||||
}).globalPlaceholder("tps", (ctx, queue) -> Tag.selfClosingInserting(Component.text(Bukkit.getTPS()[0]))).build();
|
||||
|
||||
Expansion expansion = builder.build();
|
||||
expansion.register();
|
||||
|
||||
}
|
||||
|
||||
public long checkPlayerBalance(Player player) {
|
||||
|
||||
DiamondBankOG diamondBankPlugin = new DiamondBankOG();
|
||||
|
||||
diamondBankPlugin.getPlayerBalance(player.getUniqueId(), BalanceType.BANK_BALANCE).thenAccept(balance -> {
|
||||
|
||||
balance.getBankBalance();
|
||||
|
||||
}).exceptionally(error -> {
|
||||
|
||||
// Handle potential errors...
|
||||
TemplateOG.getPlugin().getLogger().info("ERROR: Failed to get player balance! " + error);
|
||||
|
||||
// End task gracefully.
|
||||
return null;
|
||||
|
||||
});
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package plugin;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public class Utils {
|
||||
|
||||
// Sends a formatted message to the player (including name replacement).
|
||||
public static void diamondBankOGPlaceholderMessage(Player p, String message) {
|
||||
|
||||
p.sendMessage(legacySerializerAnyCase((message)));
|
||||
|
||||
}
|
||||
|
||||
public static TextComponent legacySerializerAnyCase(String subject) {
|
||||
|
||||
int count = 0;
|
||||
// Count the number of '&' characters to determine the size of the array
|
||||
for (char c : subject.toCharArray()) {
|
||||
|
||||
if (c == '&') {
|
||||
|
||||
count++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Create an array to store the positions of '&' characters
|
||||
int[] positions = new int[count];
|
||||
int index = 0;
|
||||
// Find the positions of '&' characters and store in the array
|
||||
for (int i = 0; i < subject.length(); i++) {
|
||||
|
||||
if (subject.charAt(i) == '&') {
|
||||
|
||||
if (isUpperBukkitCode(subject.charAt(i + 1))) {
|
||||
|
||||
subject = replaceCharAtIndex(subject, (i + 1), Character.toLowerCase(subject.charAt(i + 1)));
|
||||
|
||||
}
|
||||
|
||||
positions[index++] = i;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return LegacyComponentSerializer.legacyAmpersand().deserialize(subject);
|
||||
|
||||
}
|
||||
|
||||
private static boolean isUpperBukkitCode(char input) {
|
||||
|
||||
char[] bukkitColorCodes = {'A', 'B', 'C', 'D', 'E', 'F', 'K', 'L', 'M', 'N', 'O', 'R'};
|
||||
boolean match = false;
|
||||
|
||||
// Loop through each character in the array.
|
||||
for (char c : bukkitColorCodes) {
|
||||
// Check if the current character in the array is equal to the input character.
|
||||
if (c == input) {
|
||||
|
||||
match = true;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return match;
|
||||
|
||||
}
|
||||
|
||||
private static String replaceCharAtIndex(String original, int index, char newChar) {
|
||||
|
||||
// Check if the index is valid
|
||||
if (index >= 0 && index < original.length()) {
|
||||
|
||||
// Create a new string with the replaced character
|
||||
return original.substring(0, index) + newChar + original.substring(index + 1);
|
||||
|
||||
}
|
||||
|
||||
// If the index is invalid, return the original string
|
||||
return original;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,7 @@
|
||||
name: Template-OG
|
||||
author: NotAlexNoyle
|
||||
description: A blank plugin for TrueOG from which to base other plugins off of.
|
||||
website: https://github.com/true-og/Template-OG/
|
||||
name: GxUI-OG
|
||||
authors: [ Gxorge, NotAlexNoyle ]
|
||||
description: Gxorge's GUI library maintained for 1.19.4 by TrueOG Network.
|
||||
website: https://git.trueog.net/trueog/GxUI-OG
|
||||
version: '${version}'
|
||||
api-version: '${apiVersion}'
|
||||
main: plugin.TemplateOG
|
||||
depend: [DiamondBankOG]
|
||||
main: net.trueog.gxui
|
||||
Reference in new issue
Block a user