diff --git a/README.md b/README.md index 4c4f5e6..4d3de26 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@
-[![crazyauctions](https://raw.githubusercontent.com/RyderBelserion/Assets/main/crazycrew/webp/CrazyAuctionsBanner.webp)](https://modrinth.com/plugin/crazyauctions) -
+[![CrazyAuctions](https://raw.githubusercontent.com/RyderBelserion/Assets/main/crazycrew/webp/CrazyAuctionsBanner.webp)](https://modrinth.com/plugin/crazyauctions) + [![Contributors][contributors-shield]][contributors-url] [![Forks][forks-shield]][forks-url] [![Stargazers][stars-shield]][stars-url] @@ -16,14 +16,14 @@ ![Purpur](https://cdn.jsdelivr.net/gh/intergrav/devins-badges/assets/compact/supported/purpur_vector.svg)

- Auction off your items in style! + A crates plugin that offers quality crates with ease!
- Explore the docs » + Explore the docs »

Report Bug · - Request Feature + Request Feature · Get Support

@@ -47,12 +47,8 @@ -## Resource Page - -### Beta Builds -All beta builds will be on Modrinth marked as beta.
- -![Modrinth](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/cozy/available/modrinth_64h.png) +### Resource Page +![Modrinth](https://raw.githubusercontent.com/intergrav/devins-badges/v3/assets/compact/available/modrinth_46h.png) ## Getting Started @@ -72,14 +68,14 @@ A list of things necessary to make sure you can build CrazyAuctions properly. git clone https://github.com/Crazy-Crew/CrazyAuctions.git ``` 2. Open the repository using Intellij IDEA & wait until it finishes downloading/indexing. -3. Run the shadowJar task. +3. Run the assemble task. ```gradle - ./gradlew shadowJar + ./gradlew assemble ``` ## Roadmap -Check our public [trello board](https://trello.com/b/CcPYmsBt) for our current plans, any bugs and general tracking of the project progress. +Check our public [trello board](https://trello.com/b/bzQ5TwXo) for our current plans, any bugs and general tracking of the project progress. ## Contributing @@ -87,7 +83,7 @@ Check our public [trello board](https://trello.com/b/CcPYmsBt) for our current p 2. Create your Feature Branch (`git checkout -b feature/yourfeature`) 3. Commit your Changes (`git commit -m 'your amazing feature.'`) 4. Push to the Branch (`git push`) -5. Open a Pull Request to the dev branch to add your feature/fix. +5. Open a Pull Request to the `main` branch to add your feature/fix. ## License @@ -107,4 +103,4 @@ Distributed under the MIT License. See [`LICENSE`](/LICENSE) for more informatio [license-shield]: https://img.shields.io/github/license/Crazy-Crew/CrazyAuctions.svg?style=flat&logo=appveyor [license-url]: https://github.com/Crazy-Crew/CrazyAuctions/blob/master/LICENSE -[codefactor-shield]: https://img.shields.io/codefactor/grade/github/crazy-crew/CrazyAuctions/main?style=flat&logo=appveyor +[codefactor-shield]: https://img.shields.io/codefactor/grade/github/crazy-crew/CrazyAuctions/main?style=flat&logo=appveyor \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index bb01595..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,57 +0,0 @@ -plugins { - id("root-plugin") -} - -defaultTasks("build") - -rootProject.group = "com.badbones69.crazyauctions" -rootProject.description = "Auction off your items in style!" -rootProject.version = "2.0.0-rc1" - -val combine by tasks.registering(Jar::class) { - dependsOn("build") - duplicatesStrategy = DuplicatesStrategy.EXCLUDE - - from(files(subprojects.map { - it.layout.buildDirectory.file("libs/${rootProject.name}-${it.name}-${it.version}.jar").get() - }).filter { it.name != "MANIFEST.MF" }.map { if (it.isDirectory) it else zipTree(it) }) -} - -allprojects { - listOf( - ":core", - ":paper" - ).forEach { - project(it) { - apply(plugin = "java") - - if (this.name == "paper") { - dependencies { - implementation("org.bstats", "bstats-bukkit", "3.0.2") - - compileOnly("com.github.MilkBowl", "VaultAPI", "1.7.1") { - exclude("org.bukkit", "bukkit") - } - } - } - - dependencies { - implementation("ch.jalu", "configme", "1.3.1") - - implementation("com.github.Carleslc.Simple-YAML", "Simple-Yaml", "1.8.4") { - exclude("org.yaml", "snakeyaml") - } - } - } - } -} - -tasks { - assemble { - subprojects.forEach { - dependsOn(":${it.project.name}:build") - } - - finalizedBy(combine) - } -} \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts deleted file mode 100644 index 39506a1..0000000 --- a/buildSrc/build.gradle.kts +++ /dev/null @@ -1,19 +0,0 @@ -plugins { - `kotlin-dsl` -} - -repositories { - gradlePluginPortal() - - maven("https://repo.crazycrew.us/first-party/") -} - -dependencies { - implementation("com.github.johnrengelman", "shadow", "8.1.1") - - implementation("io.papermc.paperweight", "paperweight-userdev", "1.5.5") - - implementation("com.ryderbelserion.feather", "feather-plugin", "0.0.0.4") - - implementation("com.modrinth.minotaur", "Minotaur", "2.8.0") -} \ No newline at end of file diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts deleted file mode 100644 index 860fd1b..0000000 --- a/buildSrc/settings.gradle.kts +++ /dev/null @@ -1,8 +0,0 @@ -dependencyResolutionManagement { - repositories { - gradlePluginPortal() - - maven("https://repo.crazycrew.us/first-party/") - maven("https://repo.crazycrew.us/third-party/") - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/paper-plugin.gradle.kts b/buildSrc/src/main/kotlin/paper-plugin.gradle.kts deleted file mode 100644 index e71a6b0..0000000 --- a/buildSrc/src/main/kotlin/paper-plugin.gradle.kts +++ /dev/null @@ -1,15 +0,0 @@ -plugins { - id("root-plugin") - - id("io.papermc.paperweight.userdev") -} - -dependencies { - paperweight.paperDevBundle("1.20.1-R0.1-SNAPSHOT") -} - -tasks { - assemble { - dependsOn(reobfJar) - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/publish-task.gradle.kts b/buildSrc/src/main/kotlin/publish-task.gradle.kts deleted file mode 100644 index 2688af1..0000000 --- a/buildSrc/src/main/kotlin/publish-task.gradle.kts +++ /dev/null @@ -1,122 +0,0 @@ -import java.io.ByteArrayOutputStream -import java.io.File - -plugins { - id("root-plugin") - - id("featherpatcher") - id("com.modrinth.minotaur") -} - -val isSnapshot = rootProject.version.toString().contains("snapshot") -val type = if (isSnapshot) "beta" else "release" - -// The commit id for the "main" branch prior to merging a pull request. -val start = "363a0d" - -// The commit id BEFORE merging the pull request so before "Merge pull request #30" -val end = "52b8d7" - -val commitLog = getGitHistory().joinToString(separator = "") { formatGitLog(it) } - -val desc = """ -## Changes: - * Added 1.20 support. - * Temporarily removed CMI Support while they update. - -## API: - * N/A - -## Bugs: - * Submit any bugs @ https://github.com/Crazy-Crew/${rootProject.name}/issues - -## Commits - -
- -Other - -$commitLog - -
- -""".trimIndent() - -val versions = listOf( - "1.20" -) - -fun getGitHistory(): List { - val output: String = ByteArrayOutputStream().use { outputStream -> - project.exec { - executable("git") - args("log", "$start..$end", "--format=format:%h %s") - standardOutput = outputStream - } - - outputStream.toString() - } - - return output.split("\n") -} - -fun formatGitLog(commitLog: String): String { - val hash = commitLog.take(7) - val message = commitLog.substring(8) // Get message after commit hash + space between - return "[$hash](https://github.com/Crazy-Crew/${rootProject.name}/commit/$hash) $message
" -} - -val javaComponent: SoftwareComponent = components["java"] - -tasks { - modrinth { - token.set(System.getenv("MODRINTH_TOKEN")) - projectId.set(rootProject.name.lowercase()) - - versionName.set("${rootProject.name} ${rootProject.version}") - versionNumber.set(rootProject.version.toString()) - - versionType.set(type) - - val file = File("$rootDir/jars") - if (!file.exists()) file.mkdirs() - - uploadFile.set(layout.buildDirectory.file("$file/${rootProject.name}-${rootProject.version}.jar")) - - autoAddDependsOn.set(true) - - gameVersions.addAll(versions) - - loaders.addAll(listOf("paper", "purpur")) - - changelog.set(desc) - } - - publishing { - publications { - create("maven") { - groupId = rootProject.group.toString() - artifactId = "${rootProject.name.lowercase()}-api" - version = rootProject.version.toString() - - from(javaComponent) - } - } - - repositories { - maven { - credentials { - this.username = System.getenv("gradle_username") - this.password = System.getenv("gradle_password") - } - - if (isSnapshot) { - url = uri("https://repo.crazycrew.us/snapshots/") - return@maven - } - - url = uri("https://repo.crazycrew.us/releases/") - } - } - } -} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/root-plugin.gradle.kts b/buildSrc/src/main/kotlin/root-plugin.gradle.kts deleted file mode 100644 index e0408c5..0000000 --- a/buildSrc/src/main/kotlin/root-plugin.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -plugins { - `java-library` - `maven-publish` - - id("com.github.johnrengelman.shadow") -} - -repositories { - maven("https://repo.mrivanplays.com/repository/other-developers/") - - maven("https://repo.mrivanplays.com/repository/maven-all/") - - maven("https://repo.codemc.io/repository/maven-public/") - - maven("https://repo.crazycrew.us/first-party/") - - maven("https://repo.crazycrew.us/third-party/") - - maven("https://jitpack.io/") - - mavenCentral() -} - -java { - toolchain.languageVersion.set(JavaLanguageVersion.of("17")) -} - -tasks { - compileJava { - options.encoding = Charsets.UTF_8.name() - options.release.set(17) - } -} \ No newline at end of file diff --git a/core/build.gradle.kts b/core/build.gradle.kts deleted file mode 100644 index 54bd8c2..0000000 --- a/core/build.gradle.kts +++ /dev/null @@ -1,33 +0,0 @@ -plugins { - id("paper-plugin") -} - -group = "${rootProject.group}.core" -version = rootProject.version - -base { - archivesName.set("${rootProject.name}-${project.name}") -} - -tasks { - assemble { - dependsOn(shadowJar) - doLast { - delete(fileTree(baseDir = "$buildDir").include("**/*-dev*.jar")) - } - } - - shadowJar { - archiveBaseName.set("${rootProject.name}-${project.name}") - archiveClassifier.set("") - mergeServiceFiles() - - listOf( - "org.bstats", - "org.simpleyaml", - "org.yaml.snakeyaml" - ).forEach { - relocate(it, "libs.$it") - } - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/ApiManager.java b/core/src/main/java/com/badbones69/crazyauctions/ApiManager.java deleted file mode 100644 index bb64051..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/ApiManager.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.badbones69.crazyauctions; - -import ch.jalu.configme.SettingsManager; -import ch.jalu.configme.SettingsManagerBuilder; -import com.badbones69.crazyauctions.config.ConfigBuilder; -import com.badbones69.crazyauctions.config.types.PluginConfig; -import com.badbones69.crazyauctions.frame.utils.FileUtils; -import java.io.File; -import java.nio.file.Path; - -public class ApiManager { - - private final Path path; - - public ApiManager(Path path) { - this.path = path; - } - - private static SettingsManager locale; - private static SettingsManager config; - private static SettingsManager pluginConfig; - - public void load() { - File pluginConfigFile = new File(this.path.toFile(), "plugin-config.yml"); - - pluginConfig = SettingsManagerBuilder - .withYamlFile(pluginConfigFile) - .useDefaultMigrationService() - .configurationData(ConfigBuilder.buildPluginConfig()) - .create(); - - File localeDir = new File(this.path.toFile(), "locale"); - FileUtils.extract("/locale/", this.path, false); - - File localeFile = new File(localeDir, pluginConfig.getProperty(PluginConfig.LOCALE_FILE) + ".yml"); - - locale = SettingsManagerBuilder - .withYamlFile(localeFile) - .useDefaultMigrationService() - .configurationData(ConfigBuilder.buildLocale()) - .create(); - - // Create config.yml - File configFile = new File(this.path.toFile(), "config.yml"); - - config = SettingsManagerBuilder - .withYamlFile(configFile) - .useDefaultMigrationService() - .configurationData(ConfigBuilder.buildConfig()) - .create(); - - } - - public void reload() { - // Reload configs. - pluginConfig.reload(); - config.reload(); - - locale.reload(); - - File localeDir = new File(this.path.toFile(), "locale"); - File localeFile = new File(localeDir, pluginConfig.getProperty(PluginConfig.LOCALE_FILE) + ".yml"); - - locale = SettingsManagerBuilder - .withYamlFile(localeFile) - .useDefaultMigrationService() - .configurationData(ConfigBuilder.buildLocale()) - .create(); - } - - public static SettingsManager getPluginConfig() { - return pluginConfig; - } - - public static SettingsManager getLocale() { - return locale; - } - - public static SettingsManager getConfig() { - return config; - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/config/ConfigBuilder.java b/core/src/main/java/com/badbones69/crazyauctions/config/ConfigBuilder.java deleted file mode 100644 index adc5a3a..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/config/ConfigBuilder.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.badbones69.crazyauctions.config; - -import ch.jalu.configme.configurationdata.ConfigurationData; -import ch.jalu.configme.configurationdata.ConfigurationDataBuilder; -import com.badbones69.crazyauctions.config.types.Config; -import com.badbones69.crazyauctions.config.types.Locale; -import com.badbones69.crazyauctions.config.types.PluginConfig; - -public class ConfigBuilder { - - private ConfigBuilder() {} - - public static ConfigurationData buildPluginConfig() { - return ConfigurationDataBuilder.createConfiguration( - PluginConfig.class - ); - } - - public static ConfigurationData buildConfig() { - return ConfigurationDataBuilder.createConfiguration( - Config.class - ); - } - - public static ConfigurationData buildLocale() { - return ConfigurationDataBuilder.createConfiguration( - Locale.class - ); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/config/types/Config.java b/core/src/main/java/com/badbones69/crazyauctions/config/types/Config.java deleted file mode 100644 index 1fbe029..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/config/types/Config.java +++ /dev/null @@ -1,43 +0,0 @@ -package com.badbones69.crazyauctions.config.types; - -import ch.jalu.configme.Comment; -import ch.jalu.configme.SettingsHolder; -import ch.jalu.configme.configurationdata.CommentsConfiguration; -import ch.jalu.configme.properties.Property; -import static ch.jalu.configme.properties.PropertyInitializer.newProperty; - -public class Config implements SettingsHolder { - - public Config() {} - - @Override - public void registerComments(CommentsConfiguration conf) { - String[] header = { - "Github: https://github.com/Crazy-Crew", - "", - "Issues: https://github.com/Crazy-Crew/CrazyAuctions/issues", - "Features: https://github.com/Crazy-Crew/CrazyAuctions//discussions/categories/features", - "", - "Legacy color codes such as &7,&c no longer work. You must use MiniMessage", - "https://docs.advntr.dev/minimessage/format.html#color" - }; - - String[] deprecation = { - "", - "Warning: This section is subject to change so it is considered deprecated.", - "This is your warning before the change happens.", - "" - }; - - conf.setComment("misc", header); - } - - @Comment("Allow damage items to be auctioned off.") - public static final Property DAMAGED_ITEMS = newProperty("misc.allow-damaged-items", false); - - @Comment("Whether or not to allow `ah sell` or not.") - public static final Property SELLING_MODULE = newProperty("modules.selling-module", true); - - @Comment("Whether or not to allow `ah buy` or not.") - public static final Property BIDDING_MODULE = newProperty("modules.bidding-module", true); -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/config/types/Locale.java b/core/src/main/java/com/badbones69/crazyauctions/config/types/Locale.java deleted file mode 100644 index 69c118d..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/config/types/Locale.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.badbones69.crazyauctions.config.types; - -import ch.jalu.configme.SettingsHolder; -import ch.jalu.configme.configurationdata.CommentsConfiguration; -import ch.jalu.configme.properties.Property; -import ch.jalu.configme.properties.PropertyInitializer; - -public class Locale implements SettingsHolder { - - public Locale() {} - - @Override - public void registerComments(CommentsConfiguration conf) { - String[] header = { - "Submit your translations here: https://github.com/Crazy-Crew/CrazyAuctions/discussions/categories/translations", - "", - "Legacy color codes such as &7,&c no longer work. You must use MiniMessage", - "https://docs.advntr.dev/minimessage/format.html#color" - }; - - String[] deprecation = { - "", - "Warning: This section is subject to change so it is considered deprecated.", - "This is your warning before the change happens.", - "" - }; - - conf.setComment("general", header); - } - - public static final Property UNKNOWN_COMMAND = PropertyInitializer.newProperty("general.unknown-command", "{prefix}The command {command} is not known."); - - public static final Property INVALID_SYNTAX = PropertyInitializer.newProperty("general.invalid-syntax", "{prefix}{value} is an invalid {action}."); - - public static final Property NO_PERMISSION = PropertyInitializer.newProperty("general.no-permission", "{prefix}You do not have permission to use that command!"); - - public static final Property REQUIRED_ARGUMENT = PropertyInitializer.newProperty("general.checks.required-argument", "{prefix}This argument is not optional"); - - public static final Property OPTIONAL_ARGUMENT = PropertyInitializer.newProperty("general.checks.optional-argument", "{prefix}This argument is optional"); - - public static final Property NOT_ENOUGH_ARGS = PropertyInitializer.newProperty("general.checks.not-enough-args", "{prefix}You did not supply enough arguments."); - - public static final Property TOO_MANY_ARGS = PropertyInitializer.newProperty("general.checks.too-many-args", "{prefix}You put more arguments then I can handle."); - - public static final Property MUST_BE_PLAYER = PropertyInitializer.newProperty("general.player-checks.must-be-player", "{prefix}You must be a player to use this command."); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/config/types/PluginConfig.java b/core/src/main/java/com/badbones69/crazyauctions/config/types/PluginConfig.java deleted file mode 100644 index d60060e..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/config/types/PluginConfig.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.badbones69.crazyauctions.config.types; - -import ch.jalu.configme.Comment; -import ch.jalu.configme.SettingsHolder; -import ch.jalu.configme.configurationdata.CommentsConfiguration; -import ch.jalu.configme.properties.Property; -import ch.jalu.configme.properties.PropertyInitializer; - -import static ch.jalu.configme.properties.PropertyInitializer.newProperty; - -/** - * Description: The plugin-settings.yml options. - */ -public class PluginConfig implements SettingsHolder { - - // Empty constructor required by SettingsHolder - public PluginConfig() {} - - @Override - public void registerComments(CommentsConfiguration conf) { - String[] header = { - "Support: https://discord.gg/crazycrew", - "Github: https://github.com/Crazy-Crew", - "", - "Issues: https://github.com/Crazy-Crew/CrazyAuctions/issues", - "Features: https://github.com/Crazy-Crew/CrazyAuctions/discussions" - }; - - conf.setComment("settings", header); - } - - @Comment({ - "Choose what language you want the plugin to be in.", - "", - "Available Languages: en-US" - }) - public static final Property LOCALE_FILE = PropertyInitializer.newProperty("language", "en-US"); - - @Comment("How many commands should be displayed per page in /crazycrates help?") - public static final Property MAX_HELP_PAGE_ENTRIES = PropertyInitializer.newProperty("help.max-help-page-entries", 10); - - public static final Property INVALID_HELP_PAGE = PropertyInitializer.newProperty("help.invalid-page", "{prefix}The page {page} does not exist."); - - public static final Property HELP_PAGE_FORMAT = PropertyInitializer.newProperty("help.page-format", "{command} » {description}"); - - public static final Property HELP_PAGE_HEADER = PropertyInitializer.newProperty("help.header", "──────── CrazyCrates Help {page} ────────"); - - public static final Property HELP_PAGE_FOOTER = PropertyInitializer.newProperty("help.footer", "──────── CrazyCrates Help {page}"); - - @Comment({ - "The only options that work here are run_command, suggest_command, copy_to_clipboard", - "", - "Warning: They are case-sensitive names so type them exactly as given above!", - "", - "This is what happens if you click the command in the /crazycrates help menu." - }) - public static final Property HELP_PAGE_HOVER_ACTION = PropertyInitializer.newProperty("help.hover.action", "copy_to_clipboard"); - - public static final Property HELP_PAGE_HOVER_FORMAT = PropertyInitializer.newProperty("help.hover.format", "{prefix}Click me to run the command. {commands}"); - - public static final Property HELP_PAGE_NEXT = PropertyInitializer.newProperty("help.page-next", " »»»"); - - public static final Property HELP_PAGE_BACK = PropertyInitializer.newProperty("help.page-back", " «««"); - - public static final Property HELP_PAGE_GO_TO_PAGE = PropertyInitializer.newProperty("help.go-to-page", "Go to page {page}"); - - @Comment("The command prefix that is shown at the beginning of every message.") - public static final Property COMMAND_PREFIX = PropertyInitializer.newProperty("commands.prefix.command-value", "[CrazyCrates] "); - - @Comment("The prefix that is shown for messages sent in console such as logging messages.") - public static final Property CONSOLE_PREFIX = PropertyInitializer.newProperty("commands.prefix.console-value", "[CrazyCrates] "); - - @Comment("Whether you want to have verbose logging enabled.") - public static final Property VERBOSE_LOGGING = PropertyInitializer.newProperty("verbose-logging", true); - - @Comment("Whether you want statistics sent to https://bstats.org.") - public static final Property TOGGLE_METRICS = PropertyInitializer.newProperty("toggle-metrics", true); -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/data/UserCache.java b/core/src/main/java/com/badbones69/crazyauctions/data/UserCache.java deleted file mode 100644 index 0c83465..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/data/UserCache.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.badbones69.crazyauctions.data; - -import java.nio.file.Path; -import java.util.UUID; - -public interface UserCache { - - /** - * Add a player to the hashmap if absent. - * - * @param uuid player uuid - */ - void addPlayer(final UUID uuid); - - /** - * Remove the player from the hashmap. - * - * @param uuid player uuid - */ - void removePlayer(final UUID uuid); - - /** - * Fetch the player if online or offline. - * - * @param uuid player uuid - * @return player object - */ - String getPlayerName(final UUID uuid); - - /** - * Fetch the uuid file of the player. - * - * @param path the path i.e. 'CrazyAuctions/userdata/random-uuid.' - * @param uuid the player uuid - * @return the complete path - */ - Path getFile(final Path path, UUID uuid); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/CrazyCore.java b/core/src/main/java/com/badbones69/crazyauctions/frame/CrazyCore.java deleted file mode 100644 index 4ddd6fb..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/CrazyCore.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.badbones69.crazyauctions.frame; - -import com.badbones69.crazyauctions.frame.storage.FileHandler; -import net.kyori.adventure.audience.Audience; -import org.jetbrains.annotations.NotNull; -import java.lang.reflect.Field; -import java.nio.file.Path; - -public abstract class CrazyCore { - - public static @NotNull CrazyCore api() { - return Provider.api(); - } - - public CrazyCore() { - try { - Field api = Provider.class.getDeclaredField("api"); - api.setAccessible(true); - api.set(null, this); - } catch (NoSuchFieldException | IllegalAccessException e) { - throw new RuntimeException(e); - } - } - - protected static final class Provider { - static CrazyCore api; - - static @NotNull CrazyCore api() { - return Provider.api; - } - } - - public void enable() {} - - public void disable() {} - - public abstract Path getDirectory(); - - public abstract String getPrefix(); - - public abstract String getConsolePrefix(); - - public abstract FileHandler getFileHandler(); - - public abstract Audience adventure(); - - public abstract String commandTooFewArgs(); - - public abstract String commandTooManyArgs(); - - public abstract String commandOptionalMsg(); - - public abstract String commandRequiredMsg(); - - public abstract String commandRequirementNotPlayer(); - - public abstract String commandRequirementNoPermission(); - - public abstract String commandHelpHeader(); - - public abstract String commandHelpFooter(); - - public abstract String commandInvalidPage(); - - public abstract String commandPageFormat(); - - public abstract String commandHoverFormat(); - - public abstract String commandHoverAction(); - - public abstract String commandNavigationText(); - - public abstract String commandNavigationNextButton(); - - public abstract String commandNavigationBackButton(); -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/CrazyLogger.java b/core/src/main/java/com/badbones69/crazyauctions/frame/CrazyLogger.java deleted file mode 100644 index 19f0bb7..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/CrazyLogger.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.badbones69.crazyauctions.frame; - -import com.badbones69.crazyauctions.frame.utils.AdventureUtils; - -public class CrazyLogger { - - public static void debug(String message) { - debug(message, null); - } - - public static void debug(String message, Exception exception) { - log(CrazyCore.api().getConsolePrefix() + "[DEBUG] " + message); - - if (exception != null) exception.printStackTrace(); - } - - public static void info(String message) { - log(CrazyCore.api().getConsolePrefix() + "[INFO] " + message); - } - - public static void severe(String message) { - severe(message, null); - } - - public static void severe(String message, Exception exception) { - log(CrazyCore.api().getConsolePrefix() + "[ERROR] " + message); - - if (exception != null) exception.printStackTrace(); - } - - public static void warn(String message) { - warn(message, null); - } - - public static void warn(String message, Exception exception) { - log(CrazyCore.api().getConsolePrefix() + "[WARN] " + message); - - if (exception != null) exception.printStackTrace(); - } - - private static void log(String message) { - CrazyCore.api().adventure().sendMessage(AdventureUtils.parse(message)); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/registry/Registry.java b/core/src/main/java/com/badbones69/crazyauctions/frame/registry/Registry.java deleted file mode 100644 index 9a2058d..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/registry/Registry.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.badbones69.crazyauctions.frame.registry; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -/** - * https://github.com/BillyGalbreath/Pl3xMap/blob/v3/LICENSE - * - * @author BillyGalbreath - */ -public class Registry implements Iterable<@NotNull T> { - - protected final Map<@NotNull String, @NotNull T> entries = new ConcurrentHashMap<>(); - - public @NotNull T register(@NotNull T value) { - return register(value.getKey(), value); - } - - public @NotNull T register(@NotNull String id, @NotNull T value) { - this.entries.put(id, value); - return value; - } - - public void unregister(@NotNull String id) { - this.entries.remove(id); - } - - public void unregister() { - Collections.unmodifiableSet(this.entries.keySet()).forEach(this::unregister); - } - - public boolean has(@NotNull String key) { - return this.entries.containsKey(key); - } - - public @Nullable T get(@NotNull String id) { - return this.entries.get(id); - } - - public @NotNull T getOrDefault(@NotNull String id, @NotNull T def) { - return this.entries.getOrDefault(id, def); - } - - public @NotNull Set> entrySet() { - return this.entries.entrySet(); - } - - public @NotNull Collection<@NotNull T> values() { - return this.entries.values(); - } - - public int size() { - return this.entries.size(); - } - - @Override - public @NotNull Iterator<@NotNull T> iterator() { - return this.entries.values().iterator(); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/registry/RegistryKey.java b/core/src/main/java/com/badbones69/crazyauctions/frame/registry/RegistryKey.java deleted file mode 100644 index 56ad7b9..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/registry/RegistryKey.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.badbones69.crazyauctions.frame.registry; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import java.util.Objects; - -/** - * https://github.com/BillyGalbreath/Pl3xMap/blob/v3/LICENSE - * - * @author BillyGalbreath - */ -public abstract class RegistryKey { - - private final String key; - - public RegistryKey(@NotNull String key) { - this.key = key; - } - - @NotNull - public String getKey() { - return this.key; - } - - @Override - public boolean equals(@Nullable Object instance) { - if (this == instance) return true; - if (instance == null) return false; - - if (this.getClass() != instance.getClass()) return false; - - RegistryKey other = (RegistryKey) instance; - return getKey().equals(other.getKey()); - }; - - @Override - public int hashCode() { - return Objects.hash(getKey()); - } - - @Override - public @NotNull String toString() { - return this.key; - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileExtension.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileExtension.java deleted file mode 100644 index 8667c41..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileExtension.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage; - -import com.badbones69.crazyauctions.frame.storage.enums.StorageType; -import com.google.gson.GsonBuilder; -import java.io.File; -import java.nio.file.Path; - -public abstract class FileExtension { - - private final String name; - private final Path path; - private final StorageType type; - - private GsonBuilder builder; - - public FileExtension(String name, Path path, StorageType type) { - this.path = path; - - this.name = name; - - this.type = type; - } - - public void setGsonBuilder(GsonBuilder builder) { - if (type != StorageType.JSON) return; - - this.builder = builder; - } - - public GsonBuilder getBuilder() { - return this.builder; - } - - public StorageType getType() { - return this.type; - } - - public String getName() { - return this.name; - } - - public File getFile() { - return new File(this.path.toFile(), this.name); - } - - public Path getPath() { - return this.path; - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileHandler.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileHandler.java deleted file mode 100644 index 7030f11..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileHandler.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage; - -import com.badbones69.crazyauctions.frame.storage.types.file.json.JsonLoader; -import com.badbones69.crazyauctions.frame.storage.types.file.yaml.YamlLoader; -import com.badbones69.crazyauctions.frame.storage.types.sql.file.SqliteLoader; -import com.badbones69.crazyauctions.frame.utils.FileUtils; -import java.io.File; -import java.nio.file.Path; - -public class FileHandler implements FileManager { - - private JsonLoader jsonLoader; - private YamlLoader yamlLoader; - private SqliteLoader sqliteLoader; - - @Override - public void addFile(FileExtension fileExtension) { - switch (fileExtension.getType()) { - - case JSON -> { - this.jsonLoader = new JsonLoader(fileExtension); - this.jsonLoader.load(); - } - - case YAML -> { - this.yamlLoader = new YamlLoader(fileExtension); - this.yamlLoader.load(); - } - - case SQLITE -> { - - } - - default -> throw new IllegalStateException("Unexpected value: " + fileExtension.getType()); - } - } - - @Override - public void saveFile(FileExtension fileExtension) { - switch (fileExtension.getType()) { - case JSON -> { - this.jsonLoader = new JsonLoader(fileExtension); - this.jsonLoader.save(); - } - - case YAML -> { - this.yamlLoader = new YamlLoader(fileExtension); - this.yamlLoader.save(); - } - - case SQLITE -> { - - } - - default -> throw new IllegalStateException("Unexpected value: " + fileExtension.getType()); - } - } - - @Override - public void removeFile(FileExtension fileExtension) { - File file = fileExtension.getPath().toFile(); - - if (file.exists()) file.delete(); - } - - @Override - public File getFile(FileExtension fileExtension) { - return fileExtension.getFile(); - } - - public void extract(String value, Path directory) { - File newDirectory = new File(directory + value); - - newDirectory.mkdir(); - - FileUtils.extract(value, directory, false); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileManager.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileManager.java deleted file mode 100644 index 4ddbc61..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/FileManager.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage; - -import java.io.File; - -public interface FileManager { - - void addFile(FileExtension fileExtension); - - void saveFile(FileExtension fileExtension); - - void removeFile(FileExtension fileExtension); - - File getFile(FileExtension fileExtension); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/enums/StorageType.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/enums/StorageType.java deleted file mode 100644 index 0017249..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/enums/StorageType.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.enums; - -import java.util.List; - -public enum StorageType { - - // Config style databases - JSON("JSON", "json"), - YAML("YAML", "yaml"), - - // Local databases - SQLITE("SQLite", "sqlite"); - - private final String name; - - private final List identifiers; - - StorageType(String name, String... identifiers) { - this.name = name; - this.identifiers = List.of(identifiers); - } - - public String getName() { - return this.name; - } - - public List getIdentifiers() { - return this.identifiers; - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/FileLoader.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/FileLoader.java deleted file mode 100644 index c86a5cd..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/FileLoader.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.file; - -public interface FileLoader { - - void load(); - - void save(); - - String getImplName(); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/json/JsonLoader.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/json/JsonLoader.java deleted file mode 100644 index 8c6ceda..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/json/JsonLoader.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.file.json; - -import com.badbones69.crazyauctions.frame.storage.FileExtension; -import com.badbones69.crazyauctions.frame.storage.enums.StorageType; -import com.badbones69.crazyauctions.frame.storage.types.file.FileLoader; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import java.io.*; -import java.lang.reflect.Modifier; -import java.nio.charset.StandardCharsets; - -public class JsonLoader implements FileLoader { - - private final FileExtension fileExtension; - - private final File file; - - private final Gson gson; - - public JsonLoader(FileExtension fileExtension) { - this.fileExtension = fileExtension; - - this.file = this.fileExtension.getFile(); - - if (this.fileExtension.getBuilder() != null) { - this.gson = this.fileExtension.getBuilder().create(); - return; - } - - GsonBuilder builder = new GsonBuilder().disableHtmlEscaping() - .excludeFieldsWithModifiers(Modifier.TRANSIENT) - .excludeFieldsWithoutExposeAnnotation(); - - this.gson = builder.create(); - } - - @Override - public void load() { - try { - if (this.file.createNewFile()) { - save(); - - return; - } - } catch (Exception exception) { - exception.printStackTrace(); - } - - try (InputStreamReader reader = new InputStreamReader(new FileInputStream(this.file), StandardCharsets.UTF_8)) { - this.gson.fromJson(reader, this.fileExtension.getClass()); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - @Override - public void save() { - try { - if (!this.file.exists()) this.file.createNewFile(); - - write(); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - - @Override - public String getImplName() { - return StorageType.JSON.getName(); - } - - private void write() throws IOException { - try (OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(this.file), StandardCharsets.UTF_8)) { - String values = this.gson.toJson(this.fileExtension, this.fileExtension.getClass()); - - writer.write(values); - } - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/YamlLoader.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/YamlLoader.java deleted file mode 100644 index 4b665ae..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/YamlLoader.java +++ /dev/null @@ -1,93 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.file.yaml; - -import com.badbones69.crazyauctions.frame.storage.FileExtension; -import com.badbones69.crazyauctions.frame.storage.enums.StorageType; -import com.badbones69.crazyauctions.frame.storage.types.file.FileLoader; -import com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys.Comment; -import com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys.Header; -import com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys.FilePath; -import org.jetbrains.annotations.NotNull; -import org.simpleyaml.configuration.comments.CommentType; -import org.simpleyaml.configuration.file.YamlFile; -import java.io.File; -import java.io.IOException; -import java.lang.reflect.Field; - -public class YamlLoader implements FileLoader { - - private final FileExtension fileExtension; - - private final File file; - - private YamlFile config; - - public @NotNull YamlFile getConfig() { - return this.config; - } - - public YamlLoader(FileExtension fileExtension) { - this.fileExtension = fileExtension; - - this.file = this.fileExtension.getFile(); - } - - protected void setComments(@NotNull String path, @NotNull String comment) { - getConfig().setComment(path, comment, CommentType.BLOCK); - } - - protected Object getValue(@NotNull String path, @NotNull Object def) { - if (this.config.get(path) == null) this.config.set(path, def); - - return this.config.get(path); - } - - @Override - public void load() { - this.config = new YamlFile(this.file); - - try { - this.config.createOrLoadWithComments(); - } catch (IOException e) { - e.printStackTrace(); - } - - for (Field field : this.getClass().getDeclaredFields()) { - field.setAccessible(true); - - FilePath filePath = field.getDeclaredAnnotation(FilePath.class); - Comment comment = field.getDeclaredAnnotation(Comment.class); - - if (filePath == null) return; - - Object pathValue = getValue(filePath.value(), comment.value()); - - try { - field.set(this.fileExtension, pathValue instanceof String stringValue ? stringValue.translateEscapes() : pathValue); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - - setComments(filePath.value(), comment.value()); - } - - Header header = this.fileExtension.getClass().getDeclaredAnnotation(Header.class); - - if (header != null) this.config.setHeader(header.value()); - - save(); - } - - @Override - public void save() { - try { - getConfig().save(); - } catch (Exception e) { - e.printStackTrace(); - } - } - - @Override - public String getImplName() { - return StorageType.YAML.getName(); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/Comment.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/Comment.java deleted file mode 100644 index faa824f..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/Comment.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys; - -import org.jetbrains.annotations.NotNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Comment { - - @NotNull String value(); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/FilePath.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/FilePath.java deleted file mode 100644 index a0353c7..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/FilePath.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys; - -import org.jetbrains.annotations.NotNull; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface FilePath { - - @NotNull String value(); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/Header.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/Header.java deleted file mode 100644 index 7ab6259..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/file/yaml/keys/Header.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.file.yaml.keys; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.TYPE) -public @interface Header { - - String value(); - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/ConnectionManager.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/ConnectionManager.java deleted file mode 100644 index fd25a33..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/ConnectionManager.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.sql; - -import java.sql.Connection; -import java.sql.SQLException; - -public interface ConnectionManager { - - String getImplName(); - - void shutdown() throws SQLException; - - Connection getConnection() throws SQLException; - -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/file/FlatFileLoader.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/file/FlatFileLoader.java deleted file mode 100644 index 046624d..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/file/FlatFileLoader.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.sql.file; - -import com.badbones69.crazyauctions.frame.storage.types.sql.ConnectionManager; -import java.io.File; -import java.nio.file.Path; -import java.sql.Connection; -import java.sql.SQLException; - -abstract class FlatFileLoader implements ConnectionManager { - - protected abstract Connection createConnection(String name, Path path) throws SQLException; - - private Connection connection; - private final String name; - private final Path path; - - FlatFileLoader(String name, Path path) { - this.name = name; - - this.path = path; - } - - @Override - public synchronized Connection getConnection() { - try { - if (this.connection == null || this.connection.isClosed()) this.connection = createConnection(this.name, this.path); - } catch (SQLException e) { - e.printStackTrace(); - } - - return this.connection; - } - - @Override - public void shutdown() { - if (this.connection != null) { - try { - this.connection.close(); - } catch (SQLException e) { - e.printStackTrace(); - } - } - } - - protected File getFile() { - return new File(this.path.toFile(), this.name); - } - - protected String getName() { - return this.name; - } - - protected Path getPath() { - return this.path; - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/file/SqliteLoader.java b/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/file/SqliteLoader.java deleted file mode 100644 index 529a883..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/storage/types/sql/file/SqliteLoader.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.badbones69.crazyauctions.frame.storage.types.sql.file; - -import com.badbones69.crazyauctions.frame.storage.enums.StorageType; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.sql.Connection; - -public class SqliteLoader extends FlatFileLoader { - - private Connection connection; - - public SqliteLoader(String name, Path path) { - super(name, path); - } - - @Override - protected Connection createConnection(String name, Path path) { - File file = new File(path.toFile(), name); - - if (!file.exists()) { - try { - file.createNewFile(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - String url = "jdbc:sqlite:" + file.getPath(); - - return null; - } - - @Override - public String getImplName() { - return StorageType.SQLITE.getName(); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/utils/AdventureUtils.java b/core/src/main/java/com/badbones69/crazyauctions/frame/utils/AdventureUtils.java deleted file mode 100644 index dbb0add..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/utils/AdventureUtils.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.badbones69.crazyauctions.frame.utils; - -import net.kyori.adventure.audience.Audience; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.event.ClickEvent; -import net.kyori.adventure.text.event.HoverEvent; -import net.kyori.adventure.text.format.TextDecoration; -import net.kyori.adventure.text.minimessage.MiniMessage; -import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver; -import org.jetbrains.annotations.NotNull; - -public class AdventureUtils { - - public static Component parse(@NotNull String message, @NotNull TagResolver.Single... placeholders) { - return MiniMessage.miniMessage().deserialize(message, placeholders).decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE); - } - - public static void send(Audience audience, String component, boolean isEnabled, String prefix) { - audience.sendMessage(isEnabled ? parse(prefix).append(parse(component)) : parse(component)); - } - - public static void hover(Audience audience, String message, String text, String value, ClickEvent.Action action) { - Component textComponent = parse(message) - .hoverEvent(HoverEvent.showText(parse(text))) - .clickEvent(ClickEvent.clickEvent(action, value)); - - audience.sendMessage(textComponent); - } - - public static void hover(Audience audience, String message, String text, String button, String value, ClickEvent.Action action) { - Component textComponent = parse(message) - .append(parse(button).hoverEvent(HoverEvent.showText(parse(text)))) - .clickEvent(ClickEvent.clickEvent(action, value)); - - audience.sendMessage(textComponent); - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/frame/utils/FileUtils.java b/core/src/main/java/com/badbones69/crazyauctions/frame/utils/FileUtils.java deleted file mode 100644 index 3037ad9..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/frame/utils/FileUtils.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.badbones69.crazyauctions.frame.utils; - -import java.io.BufferedOutputStream; -import java.io.FileOutputStream; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.JarURLConnection; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.Enumeration; -import java.util.zip.ZipEntry; -import java.util.zip.ZipFile; - -/** - * https://github.com/BillyGalbreath/Pl3xMap/blob/v3/LICENSE - * - * @author BillyGalbreath - */ -public class FileUtils { - - /** - * Extracts files from inside the .jar into an output - * - * @param input the directory in the .jar - * @param output the output wherever you use this. - * @param replace if we should replace or not. - */ - public static void extract(String input, Path output, boolean replace) { - URL directory = FileUtils.class.getResource(input); - - if (directory == null) return; - - if (!directory.getProtocol().equals("jar")) return; - - ZipFile jar; - - try { - jar = ((JarURLConnection) directory.openConnection()).getJarFile(); - } catch (Exception exception) { - throw new RuntimeException(exception); - } - - String filePath = input.substring(1); - Enumeration fileEntries = jar.entries(); - - while (fileEntries.hasMoreElements()) { - ZipEntry entry = fileEntries.nextElement(); - String entryName = entry.getName(); - - if (!entryName.startsWith(filePath)) continue; - - Path outFile = output.resolve(entryName); - boolean exists = Files.exists(outFile); - - if (!replace && exists) continue; - - if (entry.isDirectory()) { - if (exists) return; - - try { - Files.createDirectories(outFile); - } catch (Exception e) { - e.printStackTrace(); - } - - continue; - } - - try (InputStream inputStream = jar.getInputStream(entry); OutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outFile.toFile()))) { - byte[] buffer = new byte[4096]; - - int readCount; - - while ((readCount = inputStream.read(buffer)) > 0) { - outputStream.write(buffer, 0, readCount); - } - - outputStream.flush(); - } catch (Exception exception) { - exception.printStackTrace(); - } - } - } -} \ No newline at end of file diff --git a/core/src/main/java/com/badbones69/crazyauctions/utils/NumberUtils.java b/core/src/main/java/com/badbones69/crazyauctions/utils/NumberUtils.java deleted file mode 100644 index 033dfce..0000000 --- a/core/src/main/java/com/badbones69/crazyauctions/utils/NumberUtils.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.badbones69.crazyauctions.utils; - -public class NumberUtils { - - public static boolean isInt(String value) { - try { - Integer.parseInt(value); - } catch (NumberFormatException nfe) { - return false; - } - - return true; - } - - public static int convertLevelInteger(String level) { - switch (level) { - case "I" -> { - return 1; - } - case "II" -> { - return 2; - } - case "III" -> { - return 3; - } - case "IV" -> { - return 4; - } - case "V" -> { - return 5; - } - case "VI" -> { - return 6; - } - case "VII" -> { - return 7; - } - case "VIII" -> { - return 8; - } - case "IX" -> { - return 9; - } - case "X" -> { - return 10; - } - - default -> { - if (isInt(level)) { - return Integer.parseInt(level); - } else { - return 0; - } - } - } - } -} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 033e24c..7f93135 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0419a89..870dc35 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index fcb6fca..1aa94a4 100644 --- a/gradlew +++ b/gradlew @@ -83,7 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit +# 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 @@ -144,7 +145,7 @@ 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 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -201,11 +202,11 @@ 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. +# 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" \ diff --git a/gradlew.bat b/gradlew.bat deleted file mode 100644 index 93e3f59..0000000 --- a/gradlew.bat +++ /dev/null @@ -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 diff --git a/paper/build.gradle.kts b/paper/build.gradle.kts deleted file mode 100644 index 1257abc..0000000 --- a/paper/build.gradle.kts +++ /dev/null @@ -1,30 +0,0 @@ -plugins { - id("paper-plugin") -} - -group = "${rootProject.group}.paper" -version = rootProject.version - -base { - archivesName.set("${rootProject.name}-${project.name}") -} - -dependencies { - implementation(project(":core")) -} - -tasks { - processResources { - val props = mapOf( - "name" to rootProject.name, - "group" to project.group, - "version" to project.version, - "description" to rootProject.description, - "apiVersion" to "1.20" - ) - - filesMatching("paper-plugin.yml") { - expand(props) - } - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java b/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java deleted file mode 100644 index de1e841..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/CrazyAuctions.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.badbones69.crazyauctions; - -import com.badbones69.crazyauctions.api.CrazyManager; -import com.badbones69.crazyauctions.api.frame.PaperCore; -import com.badbones69.crazyauctions.api.frame.command.CommandManager; -import com.badbones69.crazyauctions.commands.inventories.AuctionInventoryClick; -import com.badbones69.crazyauctions.events.DataListener; -import org.bukkit.plugin.java.JavaPlugin; - -public class CrazyAuctions extends JavaPlugin { - - private final ApiManager apiManager; - private final PaperCore paperCore; - private CommandManager commandManager; - - private CrazyManager crazyManager; - - public CrazyAuctions(ApiManager apiManager, PaperCore paperCore) { - this.apiManager = apiManager; - this.paperCore = paperCore; - } - - @Override - public void onEnable() { - this.commandManager = CommandManager.create(); - - this.crazyManager = new CrazyManager(); - this.crazyManager.load(true); - - getServer().getPluginManager().registerEvents(new DataListener(), this); - getServer().getPluginManager().registerEvents(new AuctionInventoryClick(), this); - - } - - @Override - public void onDisable() { - if (this.crazyManager != null) this.crazyManager.stop(); - } - - public ApiManager getApiManager() { - return this.apiManager; - } - - public PaperCore getPaperCore() { - return this.paperCore; - } - - public CommandManager getCommandManager() { - return this.commandManager; - } - - public CrazyManager getCrazyManager() { - return this.crazyManager; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/CrazyStarter.java b/paper/src/main/java/com/badbones69/crazyauctions/CrazyStarter.java deleted file mode 100644 index 700825f..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/CrazyStarter.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.badbones69.crazyauctions; - -import com.badbones69.crazyauctions.api.frame.PaperCore; -import io.papermc.paper.plugin.bootstrap.BootstrapContext; -import io.papermc.paper.plugin.bootstrap.PluginBootstrap; -import io.papermc.paper.plugin.bootstrap.PluginProviderContext; -import org.bukkit.Bukkit; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import com.badbones69.crazyauctions.config.types.PluginConfig; - -@SuppressWarnings("ALL") -public class CrazyStarter implements PluginBootstrap { - - private ApiManager apiManager; - - @Override - public void bootstrap(@NotNull BootstrapContext context) { - this.apiManager = new ApiManager(context.getDataDirectory()); - this.apiManager.load(); - } - - @Override - public @NotNull JavaPlugin createPlugin(@NotNull PluginProviderContext context) { - PaperCore paperCore = new PaperCore(context.getDataDirectory(), Bukkit.getConsoleSender(), ApiManager.getPluginConfig().getProperty(PluginConfig.COMMAND_PREFIX), ApiManager.getPluginConfig().getProperty(PluginConfig.CONSOLE_PREFIX)); - paperCore.enable(); - - return new CrazyAuctions(this.apiManager, paperCore); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java b/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java deleted file mode 100644 index 884856d..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/CrazyManager.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.badbones69.crazyauctions.api; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.storage.types.StorageManager; -import org.bukkit.plugin.java.JavaPlugin; - -public class CrazyManager { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private StorageManager storageManager; - - public void load(boolean serverStart) { - if (serverStart) { - this.storageManager = new StorageManager(); - - this.storageManager.init(); - } - } - - public void reload() { - if (this.plugin.getApiManager() != null) this.plugin.getApiManager().reload(); - - if (this.storageManager.getUserManager() != null) this.storageManager.getUserManager().save(false); - } - - public void stop() { - - } - - public StorageManager getStorageManager() { - return this.storageManager; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/enums/Permissions.java b/paper/src/main/java/com/badbones69/crazyauctions/api/enums/Permissions.java deleted file mode 100644 index 7f2b613..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/enums/Permissions.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.badbones69.crazyauctions.api.enums; - -import org.bukkit.permissions.PermissionDefault; - -public enum Permissions { - - PLAYER_HELP("player.help", "Gives access to the help command.", PermissionDefault.TRUE); - - private final String node; - private final String description; - private final PermissionDefault permissionDefault; - - Permissions(String node, String description, PermissionDefault permissionDefault) { - this.node = node; - this.description = description; - this.permissionDefault = permissionDefault; - } - - public String getNode() { - return this.node; - } - - public String getDescription() { - return this.description; - } - - public PermissionDefault getPermissionDefault() { - return this.permissionDefault; - } - - public String getBuiltPermission(String action) { - return "crazyauctions." + action + "." + this.node; - } - - public String getBuiltPermission() { - return "crazyauctions.command." + this.node; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/enums/support/DataSupport.java b/paper/src/main/java/com/badbones69/crazyauctions/api/enums/support/DataSupport.java deleted file mode 100644 index affcc65..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/enums/support/DataSupport.java +++ /dev/null @@ -1,19 +0,0 @@ -package com.badbones69.crazyauctions.api.enums.support; - -import com.badbones69.crazyauctions.storage.interfaces.UserManager; -import com.badbones69.crazyauctions.storage.types.file.yaml.YamlUserManager; - -public enum DataSupport { - - yaml(YamlUserManager.class); - - private final Class classObject; - - DataSupport(Class classObject) { - this.classObject = classObject; - } - - public Class getClassObject() { - return this.classObject; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionAddEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionAddEvent.java deleted file mode 100644 index ca70dfc..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionAddEvent.java +++ /dev/null @@ -1,62 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem; -import com.badbones69.crazyauctions.api.manager.objects.AuctionHouse; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when an item is added to an auction house. - */ -public class AuctionAddEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - private final AuctionItem auctionItem; - private final AuctionHouse auctionHouse; - - /** - * A constructor to include values for a bid event. - * - * @param uuid the uuid of the player who placed the bid. - * @param auctionHouse the auction house the item is being added to. - * @param auctionItem the auction item being added. - */ - public AuctionAddEvent(UUID uuid, AuctionHouse auctionHouse, AuctionItem auctionItem) { - this.uuid = uuid; - this.player = this.plugin.getServer().getPlayer(uuid); - this.auctionHouse = auctionHouse; - this.auctionItem = auctionItem; - } - - public AuctionItem getAuctionItem() { - return auctionItem; - } - - public AuctionHouse getAuctionHouse() { - return auctionHouse; - } - - public Player getPlayer() { - return this.player; - } - - public UUID getUUID() { - return this.uuid; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionBidEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionBidEvent.java deleted file mode 100644 index c928dbd..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionBidEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when a player bids on an auction. - */ -public class AuctionBidEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - - private final ItemStack item; - - private final long bidPrice; - - /** - * A constructor to include values for a bid event. - * - * @param uuid the uuid of the player who placed the bid. - * @param item the item that was bid on. - * @param bidPrice the amount of money that was bid. - */ - public AuctionBidEvent(UUID uuid, ItemStack item, long bidPrice) { - this.uuid = uuid; - - this.player = this.plugin.getServer().getPlayer(uuid); - - this.item = item; - - this.bidPrice = bidPrice; - } - - public ItemStack getBidItem() { - return this.item; - } - - public long getBidPrice() { - return this.bidPrice; - } - - public Player getPlayer() { - return this.player; - } - - public UUID getUUID() { - return this.uuid; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionBuyEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionBuyEvent.java deleted file mode 100644 index 3a37ddb..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionBuyEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when a player buys an item. - */ -public class AuctionBuyEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - - private final ItemStack item; - - private final long price; - - /** - * A constructor to include values for a buy event. - * - * @param uuid the uuid of the player who purchased the item. - * @param item the item that was purchased. - * @param price the amount of money used to buy. - */ - public AuctionBuyEvent(UUID uuid, ItemStack item, long price) { - this.uuid = uuid; - - this.player = this.plugin.getServer().getPlayer(uuid); - - this.item = item; - - this.price = price; - } - - public ItemStack getWinningItem() { - return this.item; - } - - public long getBuyPrice() { - return this.price; - } - - public Player getPlayer() { - return this.player; - } - - public UUID getUUID() { - return this.uuid; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionCancelEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionCancelEvent.java deleted file mode 100644 index 8b3e87d..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionCancelEvent.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when an auction is cancelled. - */ -public class AuctionCancelEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - private final OfflinePlayer offlinePlayer; - - private final ItemStack item; - - /** - * A constructor to include values for when an item is cancelled. - * - * @param uuid the uuid of the player whose item cancelled. - */ - public AuctionCancelEvent(UUID uuid, ItemStack item) { - this.uuid = uuid; - - this.player = this.plugin.getServer().getPlayer(uuid); - - this.offlinePlayer = this.plugin.getServer().getOfflinePlayer(uuid); - - this.item = item; - } - - /** - * @return the expired item. - */ - public ItemStack getExpiredItem() { - return this.item; - } - - /** - * Only use this when the player is online. - * - * @return the online player. - */ - public Player getPlayer() { - return this.player; - } - - /** - * Only use this when the player is offline. - * - * @return the offline player. - */ - public OfflinePlayer getOfflinePlayer() { - return this.offlinePlayer; - } - - /** - * @return the player's uuid. - */ - public UUID getUUID() { - return this.uuid; - } - - /** - * @return the handler list. - */ - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionExpireEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionExpireEvent.java deleted file mode 100644 index 62e1cd2..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionExpireEvent.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when an auction expires. - */ -public class AuctionExpireEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - - private final ItemStack item; - - /** - * A constructor to include values for when an item expired. - * - * @param uuid the uuid of the player whose auction expired. - */ - public AuctionExpireEvent(UUID uuid, ItemStack item) { - this.uuid = uuid; - - this.player = this.plugin.getServer().getPlayer(uuid); - - this.item = item; - } - - public ItemStack getExpiredItem() { - return this.item; - } - - public Player getPlayer() { - return this.player; - } - - public UUID getUUID() { - return this.uuid; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionListEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionListEvent.java deleted file mode 100644 index 43a747c..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionListEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when a player lists an item. - */ -public class AuctionListEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - - private final ItemStack item; - - private final long bidPrice; - - /** - * A constructor to include values for a bid event. - * - * @param uuid the uuid of the player who placed the bid. - * @param item the item that was bid on. - * @param bidPrice the amount of money that was bid. - */ - public AuctionListEvent(UUID uuid, ItemStack item, long bidPrice) { - this.uuid = uuid; - - this.player = this.plugin.getServer().getPlayer(uuid); - - this.item = item; - - this.bidPrice = bidPrice; - } - - public ItemStack getBidItem() { - return this.item; - } - - public long getBidPrice() { - return this.bidPrice; - } - - public Player getPlayer() { - return this.player; - } - - public UUID getUUID() { - return this.uuid; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionWinEvent.java b/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionWinEvent.java deleted file mode 100644 index 8dd2ba3..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/events/AuctionWinEvent.java +++ /dev/null @@ -1,65 +0,0 @@ -package com.badbones69.crazyauctions.api.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.entity.Player; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.UUID; - -/** - * Description: This event is fired when an auction has a winner. - */ -public class AuctionWinEvent extends Event { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private static final HandlerList handlerList = new HandlerList(); - - private final UUID uuid; - private final Player player; - - private final ItemStack item; - - private final long price; - - /** - * A constructor to include values for a win event. - * - * @param uuid the uuid of the player who won the bid. - * @param item the item that was won. - * @param price the amount of money that was bid. - */ - public AuctionWinEvent(UUID uuid, ItemStack item, long price) { - this.uuid = uuid; - - this.player = this.plugin.getServer().getPlayer(uuid); - - this.item = item; - - this.price = price; - } - - public ItemStack getWinningItem() { - return this.item; - } - - public long getWinningPrice() { - return this.price; - } - - public Player getPlayer() { - return this.player; - } - - public UUID getUUID() { - return this.uuid; - } - - @Override - public @NotNull HandlerList getHandlers() { - return handlerList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/ItemUtils.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/ItemUtils.java deleted file mode 100644 index 98e128e..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/ItemUtils.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.badbones69.crazyauctions.api.frame; - -import org.bukkit.Bukkit; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class ItemUtils { - - private final Material skull = Material.PLAYER_HEAD; - - public ItemStack skull() { - return new ItemStack(skull); - } - - public boolean isPlayerSkull(Material itemStack) { - return itemStack != skull; - } - - private String getVersion() { - String version = Bukkit.getServer().getClass().getPackage().getName(); - return version.substring(version.lastIndexOf('.') + 1); - } - - public Class craftClass(String name) throws ClassNotFoundException { - return Class.forName("org.bukkit.craftbukkit." + getVersion() + "." + name); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/PaperCore.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/PaperCore.java deleted file mode 100644 index bf43192..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/PaperCore.java +++ /dev/null @@ -1,140 +0,0 @@ -package com.badbones69.crazyauctions.api.frame; - -import com.badbones69.crazyauctions.ApiManager; -import com.badbones69.crazyauctions.config.types.Locale; -import com.badbones69.crazyauctions.config.types.PluginConfig; -import com.badbones69.crazyauctions.frame.CrazyCore; -import com.badbones69.crazyauctions.frame.storage.FileHandler; -import net.kyori.adventure.audience.Audience; -import java.nio.file.Path; - -public class PaperCore extends CrazyCore { - - private final Path path; - private final Audience audience; - private final FileHandler fileHandler; - private final String prefix; - private final String consolePrefix; - - public PaperCore(Path path, Audience audience, String prefix, String consolePrefix) { - // Create directory. - this.path = path; - this.path.toFile().mkdir(); - - this.audience = audience; - this.prefix = prefix; - this.consolePrefix = consolePrefix; - - this.fileHandler = new FileHandler(); - } - - @Override - public void enable() { - super.enable(); - } - - @Override - public void disable() { - super.disable(); - } - - @Override - public Path getDirectory() { - return this.path; - } - - @Override - public String getPrefix() { - return this.prefix; - } - - @Override - public String getConsolePrefix() { - return this.consolePrefix; - } - - @Override - public FileHandler getFileHandler() { - return this.fileHandler; - } - - @Override - public Audience adventure() { - return this.audience; - } - - @Override - public String commandTooFewArgs() { - return ApiManager.getLocale().getProperty(Locale.NOT_ENOUGH_ARGS); - } - - @Override - public String commandTooManyArgs() { - return ApiManager.getLocale().getProperty(Locale.TOO_MANY_ARGS); - } - - @Override - public String commandOptionalMsg() { - return ApiManager.getLocale().getProperty(Locale.OPTIONAL_ARGUMENT); - } - - @Override - public String commandRequiredMsg() { - return ApiManager.getLocale().getProperty(Locale.REQUIRED_ARGUMENT); - } - - @Override - public String commandRequirementNotPlayer() { - return ApiManager.getLocale().getProperty(Locale.MUST_BE_PLAYER); - } - - @Override - public String commandRequirementNoPermission() { - return ApiManager.getLocale().getProperty(Locale.NO_PERMISSION); - } - - @Override - public String commandHelpHeader() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_HEADER); - } - - @Override - public String commandHelpFooter() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_FOOTER); - } - - @Override - public String commandInvalidPage() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.INVALID_HELP_PAGE); - } - - @Override - public String commandPageFormat() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_FORMAT); - } - - @Override - public String commandHoverFormat() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_HOVER_FORMAT); - } - - @Override - public String commandHoverAction() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_HOVER_ACTION); - } - - @Override - public String commandNavigationText() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_GO_TO_PAGE); - } - - @Override - public String commandNavigationNextButton() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_NEXT); - } - - @Override - public String commandNavigationBackButton() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.HELP_PAGE_BACK); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/PaperUtils.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/PaperUtils.java deleted file mode 100644 index 43e1bf3..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/PaperUtils.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.badbones69.crazyauctions.api.frame; - -public class PaperUtils { - - private static boolean hasClass(String className) { - try { - Class.forName(className); - return true; - } catch (ClassNotFoundException e) { - return false; - } - } - - public static boolean isSpigot() { - return hasClass("org.spigotmc.SpigotConfig") && !hasClass("io.papermc.paper.configuration.Configuration") || !hasClass("com.destroystokyo.paper.PaperConfig"); - } - - public static boolean isPaper() { - return hasClass("io.papermc.paper.configuration.Configuration") || hasClass("com.destroystokyo.paper.PaperConfig"); - } - - public static boolean isFolia() { - return hasClass("io.papermc.paper.threadedregions.RegionizedServer"); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/adapters/LocationTypeAdapter.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/adapters/LocationTypeAdapter.java deleted file mode 100644 index da9219f..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/adapters/LocationTypeAdapter.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.adapters; - -import com.google.gson.TypeAdapter; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import org.bukkit.Bukkit; -import org.bukkit.Location; - -import java.io.IOException; - -public class LocationTypeAdapter extends TypeAdapter { - - @Override - public void write(JsonWriter out, Location location) throws IOException { - out.beginObject(); - out.name("world").value(location.getWorld().getName()); - out.name("x").value(location.getX()); - out.name("y").value(location.getY()); - out.name("z").value(location.getZ()); - out.name("yaw").value(location.getYaw()); - out.name("pitch").value(location.getPitch()); - out.endObject(); - } - - @Override - public Location read(JsonReader reader) throws IOException { - reader.beginObject(); - - String worldName = null; - double x = 0, y = 0, z = 0; - float yaw = 0, pitch = 0; - - while (reader.hasNext()) { - String name = reader.nextName(); - - switch (name) { - case "world" -> worldName = reader.nextString(); - case "x" -> x = reader.nextDouble(); - case "y" -> y = reader.nextDouble(); - case "z" -> z = reader.nextDouble(); - case "yaw" -> yaw = (float) reader.nextDouble(); - case "pitch" -> pitch = (float) reader.nextDouble(); - default -> reader.skipValue(); - } - } - - reader.endObject(); - - assert worldName != null; - return new Location(Bukkit.getWorld(worldName), x, y, z, yaw, pitch); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandContext.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandContext.java deleted file mode 100644 index a5dd49d..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandContext.java +++ /dev/null @@ -1,268 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command; - -import com.badbones69.crazyauctions.ApiManager; -import com.badbones69.crazyauctions.api.frame.command.builders.CommandActor; -import com.badbones69.crazyauctions.api.frame.command.builders.args.CommandArgs; -import com.badbones69.crazyauctions.config.types.Locale; -import com.badbones69.crazyauctions.frame.utils.AdventureUtils; -import com.badbones69.crazyauctions.support.PlaceholderSupport; -import net.kyori.adventure.audience.Audience; -import net.kyori.adventure.text.Component; -import org.bukkit.Bukkit; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.permissions.Permission; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - -public class CommandContext implements CommandActor, CommandArgs { - - private final Audience audience; - private final List args; - private String label; - - private Player player; - - public CommandContext(Audience audience, String label, List args) { - this.audience = audience; - - if (audience instanceof Player) { - this.player = (Player) audience; - } - - this.label = label; - this.args = args; - } - - @Override - public void reply(String message) { - if (message.isBlank() || message.isEmpty()) return; - - Component component = AdventureUtils.parse(message); - - this.audience.sendMessage(component); - } - - @Override - public void reply(boolean hasPrefix, String prefix, String message) { - if (message.isBlank() || message.isEmpty()) return; - - if (hasPrefix) { - Component component = AdventureUtils.parse(prefix).append(AdventureUtils.parse(prefix)); - - this.audience.sendMessage(component); - - return; - } - - Component component = AdventureUtils.parse(message); - - this.audience.sendMessage(component); - } - - @Override - public void reply(boolean hasPrefix, String prefix, Component component) { - if (hasPrefix) { - this.audience.sendMessage(AdventureUtils.parse(prefix).append(component)); - return; - } - - this.audience.sendMessage(component); - } - - @Override - public void reply(Component component) { - this.audience.sendMessage(component); - } - - @Override - public void send(Audience audience, String message) { - if (message.isBlank() || message.isEmpty()) return; - - Component component = AdventureUtils.parse(message); - - audience.sendMessage(component); - } - - @Override - public void send(Audience audience, Component component) { - audience.sendMessage(component); - } - - @Override - public void send(Audience audience, String message, String prefix, boolean hasPrefix) { - if (hasPrefix) { - audience.sendMessage(AdventureUtils.parse(prefix).append(AdventureUtils.parse(message))); - return; - } - - send(audience, message); - } - - @Override - public void send(Audience audience, Component message, String prefix, boolean hasPrefix) { - if (hasPrefix) { - audience.sendMessage(AdventureUtils.parse(prefix).append(message)); - return; - } - - send(audience, message); - } - - @Override - public Audience getSender() { - return this.audience; - } - - @Override - public boolean isPlayer() { - return getPlayer() != null; - } - - @Override - public Player getPlayer() { - return this.player; - } - - @Override - public boolean hasPermission(Permission permission) { - return this.player.hasPermission(permission); - } - - @Override - public boolean hasPermission(String rawPermission) { - return this.player.hasPermission(rawPermission); - } - - @Override - public void setLabel(String label) { - this.label = label; - } - - @Override - public String getLabel() { - return this.label; - } - - public List getArgs() { - return Collections.unmodifiableList(this.args); - } - - @Override - public void removeArgs(int arg) { - this.args.remove(arg); - } - - @Override - public int getArgAsInt(int index, boolean notifySender) { - Integer value = null; - - try { - value = Integer.parseInt(this.args.get(index)); - } catch (NumberFormatException exception) { - if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX) - .replaceAll("\\{value}", this.args.get(index)) - .replaceAll("\\{action}", "number"))); - } - - if (value != null) return value; - - return 1; - } - - @Override - public long getArgAsLong(int index, boolean notifySender) { - Long value = null; - - try { - value = Long.parseLong(this.args.get(index)); - } catch (NumberFormatException exception) { - if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX) - .replaceAll("\\{value}", this.args.get(index)) - .replaceAll("\\{action}", "number"))); - } - - if (value != null) return value; - - return 1L; - } - - @Override - public double getArgAsDouble(int index, boolean notifySender) { - Double value = null; - - try { - value = Double.parseDouble(this.args.get(index)); - } catch (NumberFormatException exception) { - if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX) - .replaceAll("\\{value}", this.args.get(index)) - .replaceAll("\\{action}", "number"))); - } - - if (value != null) return value; - - return 0.1; - } - - @Override - public boolean getArgAsBoolean(int index, boolean notifySender) { - String lowercase = this.args.get(index).toLowerCase(); - - switch (lowercase) { - case "true", "on", "1" -> { - return true; - } - case "false", "off", "0" -> { - return false; - } - default -> { - if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX) - .replaceAll("\\{value}", this.args.get(index).toLowerCase()) - .replaceAll("\\{action}", "boolean"))); - - return false; - } - } - } - - @Override - public float getArgAsFloat(int index, boolean notifySender) { - Float value = null; - - try { - value = Float.parseFloat(this.args.get(index)); - } catch (NumberFormatException exception) { - if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX) - .replaceAll("\\{value}", this.args.get(index)) - .replaceAll("\\{action}", "number"))); - } - - if (value != null) return value; - - return 1F; - } - - @Override - public Player getArgAsPlayer(int index, boolean notifySender) { - Player player = Bukkit.getServer().getPlayer(this.args.get(index)); - - if (player == null) { - if (notifySender) reply(PlaceholderSupport.setPlaceholders(ApiManager.getLocale().getProperty(Locale.INVALID_SYNTAX) - .replaceAll("\\{value}", this.args.get(index)) - .replaceAll("\\{action}", "player"))); - - return null; - } - - return player; - } - - @Override - public OfflinePlayer getArgAsOfflinePlayer(int index) { - CompletableFuture future = CompletableFuture.supplyAsync(() -> Bukkit.getServer().getOfflinePlayer(this.args.get(index))).thenApply(OfflinePlayer::getUniqueId); - - return Bukkit.getServer().getOfflinePlayer(future.join()); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandEngine.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandEngine.java deleted file mode 100644 index b5a8fee..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandEngine.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.frame.command.builders.CommandDataEntry; -import com.badbones69.crazyauctions.api.frame.command.builders.args.Argument; -import com.badbones69.crazyauctions.frame.CrazyCore; -import com.badbones69.crazyauctions.frame.utils.AdventureUtils; -import com.badbones69.crazyauctions.support.PlaceholderSupport; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.TextComponent; -import net.kyori.adventure.text.event.ClickEvent; -import net.kyori.adventure.text.event.HoverEvent; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; -import java.util.*; - -public abstract class CommandEngine extends Command { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private final LinkedList labels = new LinkedList<>(); - public final LinkedList requiredArgs = new LinkedList<>(); - public final LinkedList optionalArgs = new LinkedList<>(); - - private final HashMap commandData = new HashMap<>(); - - protected CommandEngine(@NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List aliases) { - super(name, description, usageMessage, aliases); - } - - public void execute(CommandContext context, String[] args) { - perform(context, args); - } - - public void execute(CommandContext context) { - StringBuilder label = new StringBuilder(context.getLabel()); - - if (!context.getArgs().isEmpty()) { - for (CommandEngine engine : this.plugin.getCommandManager().getClasses()) { - boolean isPresent = context.getArgs().stream().findFirst().isPresent(); - - if (isPresent) { - label.append(" ").append(context.getArgs().get(0)); - - context.removeArgs(0); - context.setLabel(label.toString()); - - engine.execute(context); - return; - } - } - } - - if (!validate(context)) return; - - perform(context, new String[0]); - } - - @Override - public boolean execute(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { - List arguments = Arrays.asList(args); - - CommandContext context = new CommandContext( - sender, - label, - arguments - ); - - if (arguments.isEmpty()) { - execute(context); - return true; - } - - execute(context, args); - - return true; - } - - protected abstract void perform(CommandContext context, String[] args); - - private boolean validate(CommandContext context) { - if (context.getArgs().size() < this.requiredArgs.size()) { - context.reply(CrazyCore.api().commandTooFewArgs()); - sendValidFormat(context); - return false; - } - - if (context.getArgs().size() > this.requiredArgs.size() + this.optionalArgs.size()) { - context.reply(CrazyCore.api().commandTooManyArgs()); - sendValidFormat(context); - return false; - } - - return true; - } - - private void sendValidFormat(CommandContext context) { - ArrayList arguments = new ArrayList<>(); - - arguments.addAll(this.requiredArgs); - arguments.addAll(this.optionalArgs); - - this.requiredArgs.sort(Comparator.comparing(Argument::order)); - - if (context.isPlayer()) { - StringBuilder format = new StringBuilder("/" + "crazycrates:" + getLabel()); - - TextComponent.@NotNull Builder emptyComponent = Component.text(); - - StringBuilder types = new StringBuilder(); - - for (Argument arg : arguments) { - String value = this.optionalArgs.contains(arg) ? " (" + arg.name() + ") " : " <" + arg.name() + ">"; - - String msg = this.optionalArgs.contains(arg) ? CrazyCore.api().commandOptionalMsg() : CrazyCore.api().commandRequiredMsg(); - - Component argComponent = AdventureUtils.parse(value).hoverEvent(HoverEvent.showText(AdventureUtils.parse(PlaceholderSupport.setPlaceholders(msg)))).asComponent(); - - emptyComponent.append(argComponent); - - boolean isPresent = arg.argumentType().getPossibleValues().stream().findFirst().isPresent(); - - if (isPresent) types.append(" ").append(arg.argumentType().getPossibleValues().stream().findFirst().get()); - } - - TextComponent.@NotNull Builder finalComponent = emptyComponent - .hoverEvent(HoverEvent.showText(AdventureUtils.parse("Click me to insert into chat"))) - .clickEvent(ClickEvent.clickEvent(ClickEvent.Action.SUGGEST_COMMAND, format.append(types).toString())) - .append(emptyComponent.build()); - - context.reply(finalComponent.build()); - - return; - } - - StringBuilder format = new StringBuilder("/" + "crazycrates:" + getLabel()); - - for (Argument arg : arguments) { - String value = this.optionalArgs.contains(arg) ? "(" + arg.name() + ") " : "<" + arg.name() + "> "; - - format.append(value); - } - - context.reply(format.toString()); - } - - public List getLabels() { - return Collections.unmodifiableList(this.labels); - } - - public Map getCommandData() { - return Collections.unmodifiableMap(this.commandData); - } - - public List getRequiredArgs() { - return Collections.unmodifiableList(this.requiredArgs); - } - - public List getOptionalArgs() { - return Collections.unmodifiableList(this.optionalArgs); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandFlow.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandFlow.java deleted file mode 100644 index d8f80cd..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandFlow.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command; - -import com.badbones69.crazyauctions.api.frame.command.builders.CommandActor; -import com.badbones69.crazyauctions.api.frame.command.builders.CommandDataEntry; -import com.badbones69.crazyauctions.api.frame.command.builders.CommandHelpEntry; -import java.util.List; -import java.util.Map; - -public interface CommandFlow { - - void addCommand(CommandEngine engine); - - boolean hasCommand(String label); - - CommandHelpEntry generateCommandHelp(CommandActor actor); - - int defaultHelpPerPage(); - - void updateHelpPerPage(int newAmount); - - CommandDataEntry getCommand(String label); - - void removeCommand(String label); - - Map getCommands(); - - List getClasses(); - - List handleTabComplete(String[] args, CommandEngine engine); -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandManager.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandManager.java deleted file mode 100644 index 1618ac3..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/CommandManager.java +++ /dev/null @@ -1,123 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command; - -import com.badbones69.crazyauctions.api.frame.command.builders.CommandActor; -import com.badbones69.crazyauctions.api.frame.command.builders.CommandDataEntry; -import com.badbones69.crazyauctions.api.frame.command.builders.CommandHelpEntry; -import com.badbones69.crazyauctions.api.frame.command.builders.annotations.Hidden; -import com.badbones69.crazyauctions.api.frame.command.builders.args.Argument; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import java.util.*; - -public class CommandManager implements CommandFlow { - - private final HashMap commands = new HashMap<>(); - - private final LinkedList classes = new LinkedList<>(); - - private int defaultHelpPerPage = 10; - - public static CommandManager create() { - return new CommandManager(); - } - - @Override - public void addCommand(CommandEngine engine) { - // If the label already exists. We return! - if (hasCommand(engine.getLabel())) return; - - // Create data entry. - CommandDataEntry entry = new CommandDataEntry(); - - // Set visibility if annotation is present. - entry.setHidden(engine.getClass().isAnnotationPresent(Hidden.class)); - - if (entry.isHidden()) return; - - // Add to the hash-map & linked list! - this.commands.put(engine.getLabel(), entry); - this.classes.add(engine); - - // Add command to the server map! - Bukkit.getServer().getCommandMap().register("crazycrates", engine); - } - - @Override - public boolean hasCommand(String label) { - return this.commands.containsKey(label); - } - - @Override - public CommandHelpEntry generateCommandHelp(CommandActor actor) { - return new CommandHelpEntry(this, actor); - } - - @Override - public int defaultHelpPerPage() { - return this.defaultHelpPerPage; - } - - @Override - public void updateHelpPerPage(int newAmount) { - this.defaultHelpPerPage = newAmount; - } - - @Override - public CommandDataEntry getCommand(String label) { - if (hasCommand(label)) return this.commands.get(label); - - return null; - } - - @Override - public void removeCommand(String label) { - if (!hasCommand(label)) return; - - Command value = Bukkit.getServer().getCommandMap().getCommand(label); - - if (value != null && value.isRegistered()) value.unregister(Bukkit.getServer().getCommandMap()); - - this.commands.remove(label); - } - - @Override - public Map getCommands() { - return Collections.unmodifiableMap(this.commands); - } - - @Override - public List getClasses() { - return Collections.unmodifiableList(this.classes); - } - - @Override - public List handleTabComplete(String[] args, CommandEngine engine) { - List completions = Arrays.asList(args); - - if (completions.size() >= 1) { - int relativeIndex = this.classes.size(); - int argToComplete = completions.size() + 1 - relativeIndex; - if (engine.requiredArgs.size() >= argToComplete) { - ArrayList arguments = new ArrayList<>(); - - arguments.addAll(engine.requiredArgs); - arguments.addAll(engine.optionalArgs); - - ArrayList possibleValues = new ArrayList<>(); - - for (Argument argument : arguments) { - if (argument.order() == argToComplete) { - List possibleValuesArgs = argument.argumentType().getPossibleValues(); - - possibleValues = new ArrayList<>(possibleValuesArgs); - break; - } - } - - return possibleValues; - } - } - - return Collections.emptyList(); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandActor.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandActor.java deleted file mode 100644 index 2b88bab..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandActor.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders; - -import net.kyori.adventure.audience.Audience; -import net.kyori.adventure.text.Component; -import org.bukkit.entity.Player; -import org.bukkit.permissions.Permission; - -import java.util.List; - -public interface CommandActor { - - void reply(String message); - - void reply(boolean hasPrefix, String prefix, String message); - - void reply(boolean hasPrefix, String prefix, Component component); - - void reply(Component component); - - void send(Audience audience, String message); - - void send(Audience audience, Component component); - - void send(Audience audience, String message, String prefix, boolean hasPrefix); - - void send(Audience audience, Component message, String prefix, boolean hasPrefix); - - Audience getSender(); - - boolean isPlayer(); - - Player getPlayer(); - - boolean hasPermission(Permission permission); - - boolean hasPermission(String rawPermission); - - void setLabel(String alias); - - String getLabel(); - - List getArgs(); - - void removeArgs(int arg); - - //CommandHelpEntry getHelpEntry(); - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandDataEntry.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandDataEntry.java deleted file mode 100644 index 1d9d28c..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandDataEntry.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders; - -public class CommandDataEntry { - - private boolean isHidden = false; - - public void setHidden(boolean value) { - this.isHidden = value; - } - - public boolean isHidden() { - return this.isHidden; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandHelpEntry.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandHelpEntry.java deleted file mode 100644 index 8a33077..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/CommandHelpEntry.java +++ /dev/null @@ -1,156 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders; - -import com.badbones69.crazyauctions.ApiManager; -import com.badbones69.crazyauctions.api.frame.command.CommandEngine; -import com.badbones69.crazyauctions.api.frame.command.CommandManager; -import com.badbones69.crazyauctions.api.frame.command.builders.args.Argument; -import com.badbones69.crazyauctions.api.frame.command.builders.other.ComponentBuilder; -import com.badbones69.crazyauctions.config.types.PluginConfig; -import com.badbones69.crazyauctions.frame.CrazyCore; -import com.badbones69.crazyauctions.support.PlaceholderSupport; -import net.kyori.adventure.text.event.ClickEvent; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.Map; -import static com.badbones69.crazyauctions.frame.utils.AdventureUtils.hover; -import static com.badbones69.crazyauctions.frame.utils.AdventureUtils.send; - -public class CommandHelpEntry { - - private final CommandManager manager; - private final CommandActor actor; - - private int page = 1; - private int perPage; - private int totalPages; - private int totalResults; - private boolean lastPage; - - public CommandHelpEntry(CommandManager manager, CommandActor actor) { - this.manager = manager; - this.actor = actor; - - this.perPage = manager.defaultHelpPerPage(); - } - - public void showHelp() { - this.showHelp(this.actor); - } - - public void showHelp(CommandActor actor) { - int min = this.perPage * (this.page - 1); - int max = min + this.perPage; - - this.totalResults = this.manager.getCommands().size(); - - this.totalPages = this.totalResults / this.perPage; - - if (min >= this.totalResults) { - actor.reply(ApiManager.getPluginConfig().getProperty(PluginConfig.INVALID_HELP_PAGE).replaceAll("\\{page}", String.valueOf(page))); - return; - } - - Map entries = this.manager.getCommands(); - - for (int value = min; value < max; value++) { - if (this.totalResults - 1 < value) continue; - - CommandEngine command = this.manager.getClasses().get(value); - - CommandDataEntry dataEntry = entries.get(command.getLabel()); - - boolean isHidden = dataEntry.isHidden(); - - StringBuilder baseFormat = new StringBuilder("/" + command.getLabel()); - - String format = CrazyCore.api().commandPageFormat() - .replaceAll("\\{command}", baseFormat.toString()) - .replaceAll("\\{description}", command.getDescription()); - - // Only add aliases if the list isn't empty. - if (!command.getAliases().isEmpty()) baseFormat.append(" ").append(command.getLabels().get(0)); - - ArrayList arguments = new ArrayList<>(); - - arguments.addAll(command.getOptionalArgs()); - arguments.addAll(command.getRequiredArgs()); - - arguments.sort(Comparator.comparingInt(Argument::order)); - - if (actor.isPlayer()) { - StringBuilder types = new StringBuilder(); - - ComponentBuilder builder = new ComponentBuilder(); - - for (Argument arg : arguments) { - String argValue = command.optionalArgs.contains(arg) ? " (" + arg.name() + ") " : " <" + arg.name() + ">"; - - types.append(argValue); - } - - builder.setMessage(format.replaceAll("\\{args}", String.valueOf(types))); - - String hoverShit = baseFormat.append(types).toString(); - - String hoverFormat = CrazyCore.api().commandHoverFormat(); - - builder.hover(PlaceholderSupport.setPlaceholders(hoverFormat).replaceAll("\\{commands}", hoverShit)).click(hoverShit, ClickEvent.Action.valueOf(CrazyCore.api().commandHoverAction().toUpperCase())); - - actor.reply(builder.build()); - } - - String footer = CrazyCore.api().commandHelpFooter(); - - if (actor.isPlayer()) { - String text = CrazyCore.api().commandNavigationText(); - - if (page > 1) { - int number = page-1; - - hover(actor.getPlayer(), footer.replaceAll("\\{page}", String.valueOf(page)), text.replaceAll("\\{page}", String.valueOf(number)), CrazyCore.api().commandNavigationBackButton(), "/crazycrates help " + number, ClickEvent.Action.RUN_COMMAND); - } else if (page < this.manager.getClasses().size()) { - int number = page+1; - - hover(actor.getPlayer(), footer.replaceAll("\\{page}", String.valueOf(page)), text.replaceAll("\\{page}", String.valueOf(number)), CrazyCore.api().commandNavigationNextButton(), "/crazycrates help " + number, ClickEvent.Action.RUN_COMMAND); - } - } else { - send(actor.getSender(), footer.replaceAll("\\{page}", String.valueOf(page)), false, ""); - } - } - - this.lastPage = max >= this.totalResults; - } - - public void setPage(int page) { - this.page = page; - } - - public void setPerPage(int perPage) { - this.perPage = perPage; - } - - public void setPage(int page, int perPage) { - this.setPage(page); - this.setPerPage(perPage); - } - - public int getPage() { - return this.page; - } - - public int getPerPage() { - return this.perPage; - } - - public int getTotalResults() { - return this.totalResults; - } - - public int getTotalPages() { - return this.totalPages; - } - - public boolean isLastPage() { - return this.lastPage; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/annotations/Hidden.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/annotations/Hidden.java deleted file mode 100644 index 10fe620..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/annotations/Hidden.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.annotations; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@Retention(RetentionPolicy.RUNTIME) -public @interface Hidden {} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/Argument.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/Argument.java deleted file mode 100644 index b8e8dd3..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/Argument.java +++ /dev/null @@ -1,3 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args; - -public record Argument(String name, int order, ArgumentType argumentType) {} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/ArgumentType.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/ArgumentType.java deleted file mode 100644 index 3de171b..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/ArgumentType.java +++ /dev/null @@ -1,9 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args; - -import java.util.List; - -public abstract class ArgumentType { - - public abstract List getPossibleValues(); - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/CommandArgs.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/CommandArgs.java deleted file mode 100644 index b769c88..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/CommandArgs.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args; - -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; - -public interface CommandArgs { - - int getArgAsInt(int index, boolean notifySender); - - long getArgAsLong(int index, boolean notifySender); - - double getArgAsDouble(int index, boolean notifySender); - - boolean getArgAsBoolean(int index, boolean notifySender); - - float getArgAsFloat(int index, boolean notifySender); - - Player getArgAsPlayer(int index, boolean notifySender); - - OfflinePlayer getArgAsOfflinePlayer(int index); - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/BooleanArgument.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/BooleanArgument.java deleted file mode 100644 index 7311812..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/BooleanArgument.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args.builder; - -import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType; -import java.util.List; - -public class BooleanArgument extends ArgumentType { - - @Override - public List getPossibleValues() { - return List.of("true", "false"); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/DoubleArgument.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/DoubleArgument.java deleted file mode 100644 index dbc4007..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/DoubleArgument.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args.builder; - -import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; - -public class DoubleArgument extends ArgumentType { - - private final int numberCap; - - public DoubleArgument(Integer numberCap) { - if (numberCap == null) { - this.numberCap = 100; - return; - } - - this.numberCap = numberCap; - } - - @Override - public List getPossibleValues() { - List numbers = new ArrayList<>(); - - DecimalFormat decimalFormat = new DecimalFormat("0.0"); - - for (double value = 0.1; value <= this.numberCap; value += 0.1) { - String formattedNumber = decimalFormat.format(value); - numbers.add(formattedNumber); - } - - return numbers; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/FloatArgument.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/FloatArgument.java deleted file mode 100644 index 751a92e..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/FloatArgument.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args.builder; - -import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.List; - -public class FloatArgument extends ArgumentType { - - private final int numberCap; - - public FloatArgument(Integer numberCap) { - if (numberCap == null) { - this.numberCap = 100; - return; - } - - this.numberCap = numberCap; - } - - @Override - public List getPossibleValues() { - List numbers = new ArrayList<>(); - - DecimalFormat decimalFormat = new DecimalFormat("0.0f"); - - for (float value = 0.1f; value <= this.numberCap; value += 0.1f) { - String formattedValue = decimalFormat.format(value); - numbers.add(formattedValue); - } - - return numbers; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/IntArgument.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/IntArgument.java deleted file mode 100644 index be72dc9..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/IntArgument.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args.builder; - -import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType; -import java.util.ArrayList; -import java.util.List; - -public class IntArgument extends ArgumentType { - - private final int numberCap; - - public IntArgument(Integer numberCap) { - if (numberCap == null) { - this.numberCap = 100; - return; - } - - this.numberCap = numberCap; - } - - @Override - public List getPossibleValues() { - List numbers = new ArrayList<>(); - - for (int value = 1; value <= this.numberCap; value += 1) numbers.add(String.valueOf(value)); - - return numbers; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/custom/PlayerArgument.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/custom/PlayerArgument.java deleted file mode 100644 index 418a102..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/args/builder/custom/PlayerArgument.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.args.builder.custom; - -import com.badbones69.crazyauctions.api.frame.command.builders.args.ArgumentType; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import java.util.List; -import java.util.stream.Collectors; - -public class PlayerArgument extends ArgumentType { - - @Override - public List getPossibleValues() { - return Bukkit.getServer().getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/other/ComponentBuilder.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/other/ComponentBuilder.java deleted file mode 100644 index 8de7164..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/other/ComponentBuilder.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.other; - -import com.badbones69.crazyauctions.frame.utils.AdventureUtils; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.TextComponent; -import net.kyori.adventure.text.event.ClickEvent; -import net.kyori.adventure.text.event.HoverEvent; -import org.jetbrains.annotations.NotNull; - -public class ComponentBuilder { - - private String message; - - private final TextComponent.@NotNull Builder builder = Component.text(); - - private final PreciseComponentBuilder preciseBuilder; - - public ComponentBuilder() { - this.preciseBuilder = new PreciseComponentBuilder(); - } - - public void setMessage(String message) { - this.message = message; - } - - public ComponentBuilder append(Component component) { - this.builder.append(component); - - return this; - } - - public Component parse(String value) { - return AdventureUtils.parse(value); - } - - public ComponentBuilder hover(String hoverText) { - this.builder.hoverEvent(HoverEvent.showText(parse(hoverText))); - - return this; - } - - public ComponentBuilder click(String clickText, ClickEvent.Action action) { - this.builder.clickEvent(ClickEvent.clickEvent(action, clickText)); - - return this; - } - - public class PreciseComponentBuilder { - private final TextComponent.@NotNull Builder preciseBuilder = Component.text(); - - public PreciseComponentBuilder text(String text) { - this.preciseBuilder.append(parse(text)); - - return this; - } - - public PreciseComponentBuilder hoverText(String text, String hoverText) { - this.preciseBuilder.append(parse(text)); - this.preciseBuilder.hoverEvent(HoverEvent.showText(parse(hoverText))); - - return this; - } - - public PreciseComponentBuilder hoverText(String hoverText) { - this.preciseBuilder.hoverEvent(HoverEvent.showText(parse(hoverText))); - - return this; - } - - public PreciseComponentBuilder click(String clickText, ClickEvent.Action action) { - this.preciseBuilder.clickEvent(ClickEvent.clickEvent(action, clickText)); - - return this; - } - - public @NotNull TextComponent getPreciseBuilder() { - return this.preciseBuilder.build(); - } - } - - public PreciseComponentBuilder getPreciseComponent() { - return this.preciseBuilder; - } - - public @NotNull TextComponent build() { - Component message = AdventureUtils.parse(this.message); - - if (getPreciseComponent() != null) { - return this.builder.append(message).append(getPreciseComponent().getPreciseBuilder()).build(); - } - - return this.builder.append(message).build(); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/reqs/CommandRequirements.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/reqs/CommandRequirements.java deleted file mode 100644 index 209154c..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/reqs/CommandRequirements.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.reqs; - -import com.badbones69.crazyauctions.api.frame.command.CommandContext; -import com.badbones69.crazyauctions.frame.CrazyCore; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.permissions.Permission; - -public class CommandRequirements { - - private final boolean asPlayer; - private Permission permission; - private String rawPermission; - - public CommandRequirements(boolean asPlayer, Permission permission, String rawPermission) { - this.asPlayer = asPlayer; - - if (permission != null) this.permission = permission; - - if (!rawPermission.isEmpty() || !rawPermission.isBlank()) this.rawPermission = rawPermission; - } - - public boolean checkRequirements(boolean notifySender, CommandContext context) { - if (asPlayer && !context.isPlayer()) { - if (notifySender) context.reply(CrazyCore.api().commandRequirementNotPlayer()); - - // The command is not valid. - return false; - } - - // The sender is console sender so automatically valid. - if (context.getSender() instanceof ConsoleCommandSender) return true; - - if (this.permission != null && !context.hasPermission(this.permission) || this.rawPermission != null && !context.hasPermission(this.rawPermission)) { - String value = this.permission != null ? this.permission.getName() : this.rawPermission; - - if (notifySender) context.reply(CrazyCore.api().commandRequirementNoPermission().replaceAll("\\{permission}", value)); - - // The command is not valid. - return false; - } - - // The command is valid. - return true; - } - - public Permission getPermission() { - return this.permission; - } - - public String getRawPermission() { - return this.rawPermission; - } - - public boolean isPlayer() { - return this.asPlayer; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/reqs/CommandRequirementsBuilder.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/reqs/CommandRequirementsBuilder.java deleted file mode 100644 index 7e76844..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/command/builders/reqs/CommandRequirementsBuilder.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.command.builders.reqs; - -import org.bukkit.permissions.Permission; - -public class CommandRequirementsBuilder { - - private boolean asPlayer = false; - private Permission permission = null; - private String rawPermission = ""; - - public CommandRequirementsBuilder asPlayer(boolean value) { - this.asPlayer = value; - return this; - } - - public CommandRequirementsBuilder withPermission(Permission permission) { - this.permission = permission; - return this; - } - - public CommandRequirementsBuilder withOutPermission(Permission permission) { - return this; - } - - public CommandRequirementsBuilder withRawPermission(String rawPermission) { - this.rawPermission = rawPermission; - return this; - } - - public CommandRequirements build() { - return new CommandRequirements(asPlayer, permission, rawPermission); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/BaseItemBuilder.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/BaseItemBuilder.java deleted file mode 100644 index 5b4956c..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/BaseItemBuilder.java +++ /dev/null @@ -1,673 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.items; - -import com.badbones69.crazyauctions.api.frame.ItemUtils; -import com.badbones69.crazyauctions.frame.CrazyLogger; -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import net.kyori.adventure.text.Component; -import net.kyori.adventure.text.format.TextDecoration; -import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; -import org.bukkit.Bukkit; -import org.bukkit.Color; -import org.bukkit.DyeColor; -import org.bukkit.FireworkEffect; -import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.block.Banner; -import org.bukkit.block.banner.Pattern; -import org.bukkit.block.banner.PatternType; -import org.bukkit.enchantments.Enchantment; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ArmorMeta; -import org.bukkit.inventory.meta.BannerMeta; -import org.bukkit.inventory.meta.BlockStateMeta; -import org.bukkit.inventory.meta.Damageable; -import org.bukkit.inventory.meta.FireworkEffectMeta; -import org.bukkit.inventory.meta.FireworkMeta; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.inventory.meta.LeatherArmorMeta; -import org.bukkit.inventory.meta.PotionMeta; -import org.bukkit.inventory.meta.SkullMeta; -import org.bukkit.inventory.meta.trim.ArmorTrim; -import org.bukkit.inventory.meta.trim.TrimMaterial; -import org.bukkit.inventory.meta.trim.TrimPattern; -import org.bukkit.potion.PotionData; -import org.bukkit.potion.PotionType; -import org.bukkit.util.Consumer; -import java.lang.reflect.Field; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Base64; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Objects; -import java.util.UUID; -import java.util.stream.Collectors; - -public class BaseItemBuilder> { - - private final ItemUtils SKULL_CHECKER = new ItemUtils(); - - private final GsonComponentSerializer gson = GsonComponentSerializer.gson(); - - // Core. - private ItemStack itemStack; - private ItemMeta itemMeta; - - private Material material; - - // Custom Lore. - private Field LORE_FIELD; - - // Custom Model Data. - private boolean isCustomModelData; - - private int customModelData; - - // Custom Heads. - private boolean isHead; - private Field profile; - private String texture; - - // Potions - private boolean isPotion; - private boolean isTippedArrow; - private Color potionColor; - private PotionType potionType; - - // Leather. - private boolean isLeather; - private boolean isArmor; - private TrimMaterial trimMaterial; - private TrimPattern trimPattern; - private Color armorColor; - - // Banners. - private boolean isBanner; - private List patterns; - - // Shields. - private boolean isShield; - - // Firework. - private boolean isFirework; - private boolean isFireworkStar; - - // Enchantments/Flags - private boolean isDurable; - private boolean hideFlags; - private boolean isGlowing; - - protected BaseItemBuilder() { - this.itemStack = null; - this.itemMeta = null; - this.material = Material.AIR; - this.LORE_FIELD = null; - this.isCustomModelData = false; - this.customModelData = 0; - this.isHead = false; - this.profile = null; - this.texture = ""; - this.isPotion = false; - this.isTippedArrow = false; - this.potionColor = Color.WHITE; - this.potionType = PotionType.MUNDANE; - this.isLeather = false; - this.armorColor = Color.WHITE; - this.isBanner = false; - this.patterns = Collections.emptyList(); - this.isShield = false; - this.isFirework = false; - this.isFireworkStar = false; - this.isDurable = false; - this.hideFlags = false; - this.isGlowing = false; - } - - protected BaseItemBuilder(ItemStack itemStack) { - this.itemStack = itemStack; - - try { - Class metaClass = SKULL_CHECKER.craftClass("inventory.CraftMetaItem"); - - LORE_FIELD = metaClass.getDeclaredField("lore"); - LORE_FIELD.setAccessible(true); - } catch (NoSuchFieldException | ClassNotFoundException exception) { - CrazyLogger.warn("Failed to make the lore field accessible as it was not found. Perhaps an invalid item was supplied?"); - } - - this.material = itemStack.getType(); - - switch (this.material) { - case PLAYER_HEAD -> this.isHead = true; - case POTION, SPLASH_POTION -> this.isPotion = true; - case TIPPED_ARROW -> this.isTippedArrow = true; - case LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_LEGGINGS, LEATHER_BOOTS, LEATHER_HORSE_ARMOR -> this.isLeather = true; - case SHIELD -> this.isShield = true; - case FIREWORK_ROCKET -> this.isFirework = true; - case FIREWORK_STAR -> this.isFireworkStar = true; - } - - String name = this.material.name(); - - this.isArmor = name.endsWith("_HELMET") || name.endsWith("_CHESTPLATE") || name.endsWith("_LEGGINGS") || name.endsWith("_BOOTS"); - - // Accounts for all banners. - if (this.material.name().contains("BANNER")) this.isBanner = true; - - // if (this.material.name().contains("SPAWN_EGG")) this.isEgg = true; - - this.itemMeta = itemStack.hasItemMeta() ? itemStack.getItemMeta() : Bukkit.getServer().getItemFactory().getItemMeta(material); - } - - public Base setDisplayName(Component displayName) { - this.itemMeta.displayName(displayName.decorationIfAbsent(TextDecoration.ITALIC, TextDecoration.State.FALSE)); - return (Base) this; - } - - public Base setLore(Component ... lore) { - return setLore(Arrays.asList(lore)); - } - - public Base setLore(List lore) { - List jsonLore = lore.stream().filter(Objects::nonNull).map(this.gson::serialize).toList(); - - try { - LORE_FIELD.set(this.itemMeta, jsonLore); - } catch (IllegalAccessException exception) { - exception.printStackTrace(); - } - - return (Base) this; - } - - public Base addLore(Consumer> lore) { - List components; - - try { - List jsonLore = (List) LORE_FIELD.get(this.itemMeta); - - components = (jsonLore == null) ? new ArrayList<>() : jsonLore.stream().map(this.gson::deserialize).collect(Collectors.toList()); - } catch (Exception exception) { - components = new ArrayList<>(); - exception.printStackTrace(); - } - - lore.accept(components); - return (Base) this; - } - - public Base setAmount(int amount) { - this.itemStack.setAmount(amount); - return (Base) this; - } - - public Base addEnchantment(Enchantment enchantment, int level, boolean ignoreLevelRestriction) { - this.itemMeta.addEnchant(enchantment, level, ignoreLevelRestriction); - return (Base) this; - } - - public Base removeEnchantment(Enchantment enchantment) { - this.itemMeta.removeEnchant(enchantment); - return (Base) this; - } - - public Base setEnchantments(HashMap enchantments, boolean ignoreLevelRestriction) { - enchantments.forEach((enchantment, integer) -> this.itemMeta.addEnchant(enchantment, integer, ignoreLevelRestriction)); - return (Base) this; - } - - public Base addPatterns(List patterns) { - patterns.forEach(this::addPatterns); - return (Base) this; - } - - public Base addPattern(Pattern pattern) { - this.patterns.add(pattern); - return (Base) this; - } - - public Base setPattern(List patterns) { - this.patterns = patterns; - return (Base) this; - } - - public Base addItemFlags(List flags) { - flags.forEach(flag -> { - try { - ItemFlag itemFlag = ItemFlag.valueOf(flag.toUpperCase()); - - addItemFlag(itemFlag); - } catch (Exception exception) { - CrazyLogger.warn("Failed to add item flag: " + flag + ". The flag is invalid!"); - } - }); - - return (Base) this; - } - - public Base setTexture(String texture) { - this.texture = texture; - - return (Base) this; - } - - public Base setValue(String material) { - if (material == null || material.isEmpty()) { - CrazyLogger.warn("Material cannot be null or empty, Output: " + material + "."); - CrazyLogger.warn("Please take a screenshot of this before asking for support."); - - return (Base) this; - } - - String metaData; - - if (isPotion || isTippedArrow) { - if (material.contains(";")) { - String[] section = material.split(";"); - - String[] sectionOne = section[0].split(":"); - String[] sectionTwo = section[1].split(":"); - - try { - this.potionType = PotionType.valueOf(sectionOne[1]); - } catch (Exception exception) { - CrazyLogger.warn("Failed to set potion type " + sectionOne[1] + ". The potion type inputted is invalid."); - } - - this.potionColor = getColor(sectionTwo[1]); - } - - return (Base) this; - } - - if (material.contains(":")) { // Sets the durability or another value option. - String[] materialSplit = material.split(":"); - - material = materialSplit[0]; - metaData = materialSplit[1]; - - if (metaData.contains("#")) { // :# - String modelData = metaData.split("#")[1]; - - if (isValidInteger(modelData)) { - this.isCustomModelData = true; - this.customModelData = Integer.parseInt(modelData); - } - } - - metaData = metaData.replace("#" + customModelData, ""); - - if (isValidInteger(metaData)) { // Value is durability. - int damage = Integer.parseInt(metaData); - - if (this.itemMeta instanceof Damageable) ((Damageable) this.itemMeta).setDamage(damage); - } else { // Value is something else. - if (isPotion) { - this.potionType = PotionType.valueOf(metaData); - - if (getColor(metaData) != null) this.potionColor = getColor(metaData); - } - - if (isLeather) this.armorColor = getColor(metaData); - } - } else if (material.contains("#")) { - String[] materialSplit = material.split("#"); - material = materialSplit[0]; - - if (isValidInteger(materialSplit[1])) { // Value is a number. - this.isCustomModelData = true; - this.customModelData = Integer.parseInt(materialSplit[1]); - } - } - - Material matchedMaterial = Material.matchMaterial(material); - - if (matchedMaterial != null) this.material = matchedMaterial; - - if (this.isArmor) ((ArmorMeta) itemMeta).setTrim(new ArmorTrim(this.trimMaterial, this.trimPattern)); - - this.itemStack.setType(this.material); - - setItemMeta(this.itemStack.getItemMeta()); - - return (Base) this; - } - - public Base hideFlags(boolean hideFlags) { - this.hideFlags = hideFlags; - return (Base) this; - } - - public Base setGlow(boolean isGlowing) { - this.isGlowing = isGlowing; - return (Base) this; - } - - public Base setTrim(TrimMaterial trimMaterial, TrimPattern trimPattern) { - this.trimMaterial = trimMaterial; - this.trimPattern = trimPattern; - - return (Base) this; - } - - public Base setDurable(boolean isDurable) { - this.isDurable = isDurable; - return (Base) this; - } - - public Base setEffect(FireworkEffect... effects) { - return setEffect(Arrays.asList(effects)); - } - - public Base setEffect(List effects) { - if (effects.isEmpty()) return (Base) this; - - if (this.isFireworkStar) { - FireworkEffectMeta effectMeta = (FireworkEffectMeta) this.getItemMeta(); - - effectMeta.setEffect(effects.get(0)); - this.setItemMeta(effectMeta); - } - - if (this.isFirework) { - FireworkMeta fireworkMeta = (FireworkMeta) this.getItemMeta(); - - fireworkMeta.addEffects(effects); - this.setItemMeta(fireworkMeta); - } - - return (Base) this; - } - - public Base setPower(int power) { - if (this.isFirework) { - FireworkMeta fireworkMeta = (FireworkMeta) this.getItemMeta(); - - fireworkMeta.setPower(power); - - this.setItemMeta(fireworkMeta); - } - - return (Base) this; - } - - public ItemStack build() { - if (this.material != Material.AIR) { - if (this.isHead) { - // Set the field to accessible. - exposeField(); - - setPlayerTexture(this.texture); - } - - if (this.isPotion || this.isTippedArrow && (this.potionType != null || this.potionColor != null)) { - PotionMeta potionMeta = (PotionMeta) this.itemMeta; - - if (this.potionType != null) potionMeta.setBasePotionData(new PotionData(this.potionType)); - - if (this.potionColor != null) potionMeta.setColor(this.potionColor); - - this.setItemMeta(potionMeta); - } - - if (this.isLeather && this.armorColor != null) { - LeatherArmorMeta leatherArmorMeta = (LeatherArmorMeta) this.itemMeta; - leatherArmorMeta.setColor(this.armorColor); - } - - if (this.isBanner && !this.patterns.isEmpty()) { - BannerMeta bannerMeta = (BannerMeta) this.itemMeta; - bannerMeta.setPatterns(this.patterns); - } - - if (this.isShield && !this.patterns.isEmpty()) { - BlockStateMeta shieldMeta = (BlockStateMeta) this.itemMeta; - Banner banner = (Banner) shieldMeta.getBlockState(); - - banner.setPatterns(this.patterns); - banner.update(); - - shieldMeta.setBlockState(banner); - } - - if (this.isCustomModelData) this.itemMeta.setCustomModelData(this.customModelData); - - if (this.hideFlags) this.itemMeta.addItemFlags(ItemFlag.values()); - - this.itemMeta.setUnbreakable(this.isDurable); - - this.addGlow(); - } else { - CrazyLogger.warn("Material cannot be AIR."); - } - - this.itemStack.setItemMeta(this.itemMeta); - - return this.itemStack; - } - - private void addItemFlag(ItemFlag itemFlag) { - this.itemMeta.addItemFlags(itemFlag); - } - - private void setPlayerTexture(String texture) { - this.texture = texture; - - Player player = Bukkit.getServer().getPlayer(this.texture); - - if (player != null) { - setOwner(player); - return; - } - - if (this.texture.startsWith("http")) { - setTexture(convert(this.texture), UUID.randomUUID()); - return; - } - - setTexture(this.texture, UUID.randomUUID()); - } - - private void setOwner(OfflinePlayer player) { - if (this.SKULL_CHECKER.isPlayerSkull(this.material)) return; - - SkullMeta skullMeta = (SkullMeta) this.getItemMeta(); - - skullMeta.setOwningPlayer(player); - - this.setItemMeta(skullMeta); - } - - private void addGlow() { - if (this.isGlowing) { - if (this.itemMeta.hasEnchants()) return; - - this.itemMeta.addEnchant(Enchantment.LUCK, 1, false); - - this.setItemMeta(this.itemMeta); - } - } - - private void exposeField() { - if (this.SKULL_CHECKER.isPlayerSkull(this.material)) return; - - Field field; - - try { - SkullMeta skullMeta = (SkullMeta) this.SKULL_CHECKER.skull().getItemMeta(); - field = skullMeta.getClass().getDeclaredField("profile"); - - field.setAccessible(true); - } catch (NoSuchFieldException exception) { - CrazyLogger.warn("Failed to make the meta field for profile accessible as it was not found. Perhaps an invalid item meta or field supplied?"); - - field = null; - } - - this.profile = field; - } - - private boolean isValidInteger(String value) { - try { - Integer.parseInt(value); - } catch (NumberFormatException exception) { - return false; - } - - return true; - } - - private Color getColor(String color) { - if (color != null) { - switch (color.toUpperCase()) { - case "AQUA" -> { - return Color.AQUA; - } - case "BLACK" -> { - return Color.BLACK; - } - case "BLUE" -> { - return Color.BLUE; - } - case "FUCHSIA" -> { - return Color.FUCHSIA; - } - case "GRAY" -> { - return Color.GRAY; - } - case "GREEN" -> { - return Color.GREEN; - } - case "LIME" -> { - return Color.LIME; - } - case "MAROON" -> { - return Color.MAROON; - } - case "NAVY" -> { - return Color.NAVY; - } - case "OLIVE" -> { - return Color.OLIVE; - } - case "ORANGE" -> { - return Color.ORANGE; - } - case "PURPLE" -> { - return Color.PURPLE; - } - case "RED" -> { - return Color.RED; - } - case "SILVER" -> { - return Color.SILVER; - } - case "TEAL" -> { - return Color.TEAL; - } - case "WHITE" -> { - return Color.WHITE; - } - case "YELLOW" -> { - return Color.YELLOW; - } - } - - try { - String[] rgb = color.split(","); - return Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2])); - } catch (Exception ignore) {} - } - - return null; - } - - private void addPatterns(String stringPattern) { - try { - String[] split = stringPattern.split(":"); - - for (PatternType pattern : PatternType.values()) { - - if (split[0].equalsIgnoreCase(pattern.name()) || split[0].equalsIgnoreCase(pattern.getIdentifier())) { - DyeColor color = getDyeColor(split[1]); - - if (color != null) this.addPattern(new Pattern(color, pattern)); - - break; - } - } - } catch (Exception ignored) {} - } - - public DyeColor getDyeColor(String color) { - if (color != null) { - try { - return DyeColor.valueOf(color.toUpperCase()); - } catch (Exception exception) { - try { - String[] rgb = color.split(","); - return DyeColor.getByColor(Color.fromRGB(Integer.parseInt(rgb[0]), Integer.parseInt(rgb[1]), Integer.parseInt(rgb[2]))); - } catch (Exception ignore) {} - } - } - - return null; - } - - private void setTexture(String texture, UUID uuid) { - if (this.SKULL_CHECKER.isPlayerSkull(this.material)) return; - - if (this.profile == null) return; - - SkullMeta skullMeta = (SkullMeta) this.itemMeta; - GameProfile gameProfile = new GameProfile(uuid, null); - - gameProfile.getProperties().put("textures", new Property("textures", texture)); - - try { - this.profile.set(skullMeta, gameProfile); - } catch (Exception exception) { - CrazyLogger.warn("Failed to set the meta & game profile. Perhaps an invalid texture?"); - CrazyLogger.warn("Your Input: " + texture + "."); - } - - setItemMeta(skullMeta); - } - - private String convert(String url) { - URL actualLink; - - try { - actualLink = new URL(url); - } catch (MalformedURLException e) { - throw new RuntimeException(e); - } - - String encode = "{\"textures\":{\"SKIN\":{\"url\":\"" + actualLink + "\"}}}"; - - return Base64.getEncoder().encodeToString(encode.getBytes()); - } - - // Protected getters for extended builders. - protected ItemStack getItemStack() { - return this.itemStack; - } - - protected void setItemStack(ItemStack itemStack) { - this.itemStack = itemStack; - } - - protected ItemMeta getItemMeta() { - return this.itemMeta; - } - - protected void setItemMeta(ItemMeta itemMeta) { - this.itemMeta = itemMeta; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/ItemBuilder.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/ItemBuilder.java deleted file mode 100644 index 4c6d422..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/ItemBuilder.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.items; - -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; - -public class ItemBuilder extends BaseItemBuilder { - - public ItemBuilder() { - super(); - } - - public ItemBuilder(ItemStack itemStack) { - super(itemStack); - } - - public static ItemBuilder setStack(ItemStack itemStack) { - return new ItemBuilder(itemStack); - } - - public static ItemBuilder setMaterial(Material material) { - return new ItemBuilder(new ItemStack(material)); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/ItemNbt.java b/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/ItemNbt.java deleted file mode 100644 index f4ce10f..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/frame/items/ItemNbt.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.badbones69.crazyauctions.api.frame.items; - -import org.bukkit.NamespacedKey; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.persistence.PersistentDataType; -import org.bukkit.plugin.java.JavaPlugin; - -public class ItemNbt { - - private final JavaPlugin plugin; - - public ItemNbt(JavaPlugin plugin) { - this.plugin = plugin; - } - - public ItemStack setString(ItemStack itemStack, String key, String value) { - ItemMeta meta = itemStack.getItemMeta(); - - if (meta == null) return null; - - meta.getPersistentDataContainer().set(new NamespacedKey(this.plugin, key), PersistentDataType.STRING, value); - itemStack.setItemMeta(meta); - - return itemStack; - } - - public String getString(ItemStack itemStack, String key) { - ItemMeta meta = itemStack.getItemMeta(); - - if (meta == null) return null; - - return meta.getPersistentDataContainer().get(new NamespacedKey(this.plugin, key), PersistentDataType.STRING); - } - - public ItemStack setBoolean(ItemStack itemStack, String key, boolean value) { - ItemMeta meta = itemStack.getItemMeta(); - - if (meta == null) return null; - - meta.getPersistentDataContainer().set(new NamespacedKey(this.plugin, key), PersistentDataType.BOOLEAN, value); - itemStack.setItemMeta(meta); - - return itemStack; - } - - public ItemStack removeTag(ItemStack itemStack, String key) { - ItemMeta meta = itemStack.getItemMeta(); - - if (meta == null) return null; - - meta.getPersistentDataContainer().remove(new NamespacedKey(this.plugin, key)); - itemStack.setItemMeta(meta); - - return itemStack; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/enums/AuctionType.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/enums/AuctionType.java deleted file mode 100644 index ada77c8..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/enums/AuctionType.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.enums; - -/** - * Description: Defines the auction type to use - */ -public enum AuctionType { - - BID("Bid"), - SELL("Sell"); - - private final String name; - - AuctionType(String name) { - this.name = name; - } - - public static AuctionType getTypeFromName(String name) { - for (AuctionType type : AuctionType.values()) { - if (type.getName().equalsIgnoreCase(name)) return type; - } - - return null; - } - - public String getName() { - return this.name; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/interfaces/AuctionItem.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/interfaces/AuctionItem.java deleted file mode 100644 index d365f3f..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/interfaces/AuctionItem.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.interfaces; - -import com.badbones69.crazyauctions.api.manager.enums.AuctionType; -import org.bukkit.inventory.ItemStack; -import java.util.UUID; - -public interface AuctionItem { - - UUID auctionID = UUID.randomUUID(); - - default UUID getAuctionID() { - return auctionID; - } - - AuctionType getAuctionType(); - - UUID getSeller(); - - long getPrice(); - - long getExpireTime(); - - ItemStack getSellingItem(); - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionButtons.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionButtons.java deleted file mode 100644 index 761622f..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionButtons.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.objects; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.plugin.java.JavaPlugin; - -public class AuctionButtons { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - /* - private final ItemBuilder sellingItemsButton; - private final ItemBuilder sellingInfoButton; - private final ItemBuilder biddingInfoButton; - private final ItemBuilder currentListingsInfoButton; - private final ItemBuilder expiredItemsButton; - private final ItemBuilder expiredInfoButton; - private final ItemBuilder categoriesButton; - private final ItemBuilder categoriesInfoButton; - private final ItemBuilder nextPageButton; - private final ItemBuilder refreshPageButton; - private final ItemBuilder backPageButton; - private final ItemBuilder switchModeButton; - - public AuctionButtons(FileConfiguration file) { - String path = "auction-house.settings.buttons."; - sellingItemsButton = ItemUtils.convertString(file.getString(path + "selling-items")); - sellingInfoButton = ItemUtils.convertString(file.getString(path + "info.selling-items")); - biddingInfoButton = ItemUtils.convertString(file.getString(path + "info.bidding")); - currentListingsInfoButton = ItemUtils.convertString(file.getString(path + "info.current-listings")); - expiredItemsButton = ItemUtils.convertString(file.getString(path + "expired-items")); - expiredInfoButton = ItemUtils.convertString(file.getString(path + "info.expired-items")); - categoriesButton = ItemUtils.convertString(file.getString(path + "categories")); - categoriesInfoButton = ItemUtils.convertString(file.getString(path + "info.categories")); - nextPageButton = ItemUtils.convertString(file.getString(path + "next-page")); - refreshPageButton = ItemUtils.convertString(file.getString(path + "refresh-page")); - backPageButton = ItemUtils.convertString(file.getString(path + "back-page")); - switchModeButton = ItemUtils.convertString(file.getString(path + "switch-mode")); - } - - - public ItemBuilder getSellingItemsButton() { - return sellingItemsButton; - } - - public ItemBuilder getSellingInfoButton() { - return sellingInfoButton; - } - - public ItemBuilder getBiddingInfoButton() { - return biddingInfoButton; - } - - public ItemBuilder getCurrentListingsInfoButton() { - return currentListingsInfoButton; - } - - public ItemBuilder getExpiredItemsButton() { - return expiredItemsButton; - } - - public ItemBuilder getExpiredInfoButton() { - return expiredInfoButton; - } - - public ItemBuilder getCategoriesButton() { - return categoriesButton; - } - - public ItemBuilder getCategoriesInfoButton() { - return categoriesInfoButton; - } - - public ItemBuilder getNextPageButton() { - return nextPageButton; - } - - public ItemBuilder getRefreshPageButton() { - return refreshPageButton; - } - - public ItemBuilder getBackPageButton() { - return backPageButton; - } - - public ItemBuilder getSwitchModeButton() { - return switchModeButton; - }*/ -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionCategory.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionCategory.java deleted file mode 100644 index 5b63411..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionCategory.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.objects; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.frame.items.ItemBuilder; -import org.bukkit.Material; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.List; - -/** - * Description: Creates the auction categories - */ -public class AuctionCategory { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private String name; - private int slot; - //private ItemBuilder displayItem; - private List categoryItemList; - - //TODO make it so each AH can have their own categories and the default ones should be able to be disabled. - public AuctionCategory(String name, int slot, ItemBuilder displayItem, List categoryItemList) { - this.name = name; - this.slot = slot; - //this.displayItem = displayItem; - this.categoryItemList = categoryItemList; - } - - public String getName() { - return name; - } - - public int getSlot() { - return slot; - } - - //public ItemBuilder getDisplayItem() { - // return displayItem; - //} - - public List getCategoryItemList() { - return categoryItemList; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionHouse.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionHouse.java deleted file mode 100644 index e0b3727..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/AuctionHouse.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.objects; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.manager.enums.AuctionType; -import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem; -import com.badbones69.crazyauctions.api.manager.objects.auctiontype.BiddingAuction; -import com.badbones69.crazyauctions.api.manager.objects.auctiontype.SellingAuction; -import com.badbones69.crazyauctions.api.events.AuctionAddEvent; -import org.bukkit.Bukkit; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -/** - * Description: Creates the main auction house menu - */ -public class AuctionHouse { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private String name; - private FileConfiguration auctionFile; - private InventorySettings inventorySettings; - private List auctionItems = new ArrayList<>(); - private List auctionCategories = new ArrayList<>(); - - public AuctionHouse(FileConfiguration file) { - this.name = file.getString("auction-house.settings.name"); - this.auctionFile = file; - this.inventorySettings = new InventorySettings(file); - //Loads the auction house listings into the auction house. - //TODO this needs to be moved to a seperated data file that doesnt hold all the auction house settings. - for (String auctionID : file.getConfigurationSection("auction-house.item-on-auction").getKeys(false)) { - String path = "auction-house.item-on-auction" + auctionID + "."; - AuctionType auctionType = AuctionType.getTypeFromName(file.getString(path + "auction-type")); - if (auctionType == AuctionType.SELL) { - auctionItems.add(new SellingAuction( - UUID.fromString(file.getString(path + "seller-uuid")), - file.getLong(path + "price"), - file.getLong(path + "expire-time"), - file.getItemStack(path + "selling-item"))); - } else { - auctionItems.add(new BiddingAuction( - UUID.fromString(file.getString(path + "seller-uuid")), - UUID.fromString(file.getString(path + "highest-bidder-uuid")), - file.getLong(path + "price"), - file.getLong(path + "current-bid"), - file.getLong(path + "expire-time"), - file.getItemStack(path + "selling-item"))); - } - } - //Loads the category items into the auction house. - //TODO Need to add the default categories like isPotion, isArmor, isFood, Ect... - //for (String category : file.getConfigurationSection("auction-house.categories").getKeys(false)) { - // String path = "auction-house.categories." + category + "."; - // auctionCategories.add(new AuctionCategory( - // category, - // file.getInt(path + "slot"), - //ItemUtils.convertString(file.getString(path + "item")), - //file.getStringList(path + "items").stream().map(Material :: matchMaterial).collect(Collectors.toList()))); - //} - } - - public String getName() { - return name; - } - - public FileConfiguration getAuctionFile() { - return auctionFile; - } - - public InventorySettings getInventorySettings() { - return inventorySettings; - } - - public List getAuctionItems() { - return auctionItems; - } - - public long getAuctionCount(AuctionType auctionType) { - return auctionItems.stream().filter(auctionItem -> auctionType == auctionItem.getAuctionType()).count(); - } - - public void addAuctionItem(AuctionItem auctionItem) { - auctionItems.add(auctionItem); - AuctionAddEvent event = new AuctionAddEvent(auctionItem.getSeller(), this, auctionItem); - Bukkit.getServer().getPluginManager().callEvent(event); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/InventorySettings.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/InventorySettings.java deleted file mode 100644 index 3170b66..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/InventorySettings.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.objects; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.configuration.file.FileConfiguration; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * Description: Creates the auction house inventory settings - */ -public class InventorySettings { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private final String title; - private final AuctionButtons auctionButtons = null; - - public InventorySettings(FileConfiguration file) { - String path = "auction-house.settings."; - this.title = file.getString(path + "inventory-title"); - //this.auctionButtons = new AuctionButtons(file); - } - - public String getTitle() { - return title; - } - - public AuctionButtons getAuctionButtons() { - return auctionButtons; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/auctiontype/BiddingAuction.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/auctiontype/BiddingAuction.java deleted file mode 100644 index 14ede86..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/auctiontype/BiddingAuction.java +++ /dev/null @@ -1,74 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.objects.auctiontype; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.manager.enums.AuctionType; -import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.UUID; - -/** - * Description: Creates the bidding auction type - */ -public class BiddingAuction implements AuctionItem { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - AuctionType auctionType = AuctionType.BID; - UUID seller; - UUID highestBidder; - long price; - long currentBid; - long expireTime; - ItemStack sellingItem; - - public BiddingAuction(UUID seller, UUID highestBidder, long price, long currentBid, long expireTime, ItemStack sellingItem) { - this.seller = seller; - this.highestBidder = highestBidder; - this.price = price; - this.currentBid = 0; - this.expireTime = expireTime; - this.sellingItem = sellingItem; - } - - @Override - public AuctionType getAuctionType() { - return auctionType; - } - - @Override - public UUID getSeller() { - return seller; - } - - public UUID getHighestBidder() { - return highestBidder; - } - - public void setHighestBidder(UUID highestBidder) { - this.highestBidder = highestBidder; - } - - @Override - public long getPrice() { - return price; - } - - public long getCurrentBid() { - return currentBid; - } - - public void setCurrentBid(long currentBid) { - this.currentBid = currentBid; - } - - @Override - public long getExpireTime() { - return expireTime; - } - - @Override - public ItemStack getSellingItem() { - return sellingItem; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/auctiontype/SellingAuction.java b/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/auctiontype/SellingAuction.java deleted file mode 100644 index 12a2578..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/api/manager/objects/auctiontype/SellingAuction.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.badbones69.crazyauctions.api.manager.objects.auctiontype; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.manager.enums.AuctionType; -import com.badbones69.crazyauctions.api.manager.interfaces.AuctionItem; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.UUID; - -/** - * Description: Creates the selling auction type - */ -public class SellingAuction implements AuctionItem { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - AuctionType auctionType = AuctionType.SELL; - UUID seller; - long price; - long expireTime; - ItemStack sellingItem; - - public SellingAuction(UUID seller, long price, long expireTime, ItemStack sellingItem) { - this.seller = seller; - this.price = price; - this.expireTime = expireTime; - this.sellingItem = sellingItem; - } - - @Override - public AuctionType getAuctionType() { - return auctionType; - } - - @Override - public UUID getSeller() { - return seller; - } - - @Override - public long getPrice() { - return price; - } - - @Override - public long getExpireTime() { - return expireTime; - } - - @Override - public ItemStack getSellingItem() { - return sellingItem; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/commands/AuctionCommand.java b/paper/src/main/java/com/badbones69/crazyauctions/commands/AuctionCommand.java deleted file mode 100644 index 68135c4..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/commands/AuctionCommand.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.badbones69.crazyauctions.commands; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.frame.command.CommandContext; -import com.badbones69.crazyauctions.api.frame.command.CommandEngine; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.Collections; - -public class AuctionCommand extends CommandEngine { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - protected AuctionCommand() { - super("auctions", "Opens the auction house", "/crazyauctions:auctions", Collections.emptyList()); - } - - @Override - protected void perform(CommandContext context, String[] args) { - - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java b/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java deleted file mode 100644 index bd2479d..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/commands/admin/CommandReload.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.badbones69.crazyauctions.commands.admin; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.api.CrazyManager; -import com.badbones69.crazyauctions.api.frame.command.CommandContext; -import com.badbones69.crazyauctions.api.frame.command.CommandEngine; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.Collections; - -public class CommandReload extends CommandEngine { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - private final CrazyManager crazyManager = this.plugin.getCrazyManager(); - - public CommandReload() { - super("reload", "Reloads the plugin.", "/crazyauctions:reload", Collections.emptyList()); - } - - @Override - protected void perform(CommandContext context, String[] args) { - this.crazyManager.reload(); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventory.java b/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventory.java deleted file mode 100644 index a96c988..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventory.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.badbones69.crazyauctions.commands.inventories; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.InventoryHolder; -import org.bukkit.plugin.java.JavaPlugin; -import org.jetbrains.annotations.NotNull; - -public class AuctionInventory implements InventoryHolder { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private final Inventory inventory; - - public AuctionInventory() { - this.inventory = plugin.getServer().createInventory(this, 9); - } - - @Override - public @NotNull Inventory getInventory() { - return this.inventory; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventoryClick.java b/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventoryClick.java deleted file mode 100644 index fb49a6c..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/commands/inventories/AuctionInventoryClick.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.badbones69.crazyauctions.commands.inventories; - -import com.badbones69.crazyauctions.api.frame.items.ItemBuilder; -import com.badbones69.crazyauctions.frame.utils.AdventureUtils; -import org.bukkit.Material; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.inventory.InventoryClickEvent; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -public class AuctionInventoryClick implements Listener { - - @EventHandler - public void onAuctionClick(InventoryClickEvent event) { - Inventory inventory = event.getClickedInventory(); - - if (inventory == null || (!(inventory.getHolder() instanceof AuctionInventory auctionInventory))) return; - - event.setCancelled(true); - - ItemStack clicked = event.getCurrentItem(); - - if (clicked != null) { - event.getWhoClicked().sendMessage("Beep Boo Boo Beep!"); - - ItemBuilder builder = ItemBuilder.setStack(new ItemStack(Material.DIAMOND_SWORD)); - - builder.setAmount(3); - builder.setDisplayName(AdventureUtils.parse("This is a test")); - - auctionInventory.getInventory().addItem(builder.build()); - } - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/events/DataListener.java b/paper/src/main/java/com/badbones69/crazyauctions/events/DataListener.java deleted file mode 100644 index 5d230ae..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/events/DataListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.badbones69.crazyauctions.events; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.storage.interfaces.UserManager; -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerJoinEvent; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - -public class DataListener implements Listener { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private final UserManager userManager = this.plugin.getCrazyManager().getStorageManager().getUserManager(); - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onPlayerJoin(PlayerJoinEvent event) { - this.userManager.load(event.getPlayer().getUniqueId()); - } - - @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) - public void onPlayerQuit(PlayerQuitEvent event) { - this.userManager.saveSingular(event.getPlayer().getUniqueId(), true); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java deleted file mode 100644 index fd76a9a..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/storage/interfaces/UserManager.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.badbones69.crazyauctions.storage.interfaces; - -import com.badbones69.crazyauctions.frame.storage.enums.StorageType; -import com.badbones69.crazyauctions.storage.objects.UserData; -import java.io.File; -import java.nio.file.Path; -import java.util.Map; -import java.util.UUID; - -public interface UserManager { - - void load(UUID uuid); - - void saveSingular(UUID uuid, boolean serverExit); - - void save(boolean serverExit); - - void convert(File file, UUID uuid, StorageType storageType); - - void addAuction(UUID uuid); - - File getFile(Path path, UUID uuid); - - UserData getUser(UUID uuid); - - Map getUsers(); - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/objects/UserData.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/objects/UserData.java deleted file mode 100644 index e39dc32..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/storage/objects/UserData.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.badbones69.crazyauctions.storage.objects; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -public class UserData { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private final UUID uuid; - - private ConcurrentHashMap auctionData = new ConcurrentHashMap<>(); - - public UserData(UUID uuid) { - this.uuid = uuid; - } - - public Player getPlayer() { - return this.plugin.getServer().getPlayer(this.uuid); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/StorageManager.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/types/StorageManager.java deleted file mode 100644 index c978530..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/StorageManager.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.badbones69.crazyauctions.storage.types; - -import com.badbones69.crazyauctions.storage.interfaces.UserManager; -import com.badbones69.crazyauctions.storage.types.file.yaml.YamlUserManager; - -public class StorageManager { - - private UserManager userManager; - - public void init() { - this.userManager = new YamlUserManager(); - } - - public UserManager getUserManager() { - return this.userManager; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java b/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java deleted file mode 100644 index 5fc8f73..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/storage/types/file/yaml/YamlUserManager.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.badbones69.crazyauctions.storage.types.file.yaml; - -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.frame.storage.enums.StorageType; -import com.badbones69.crazyauctions.storage.interfaces.UserManager; -import com.badbones69.crazyauctions.storage.objects.UserData; -import org.bukkit.configuration.InvalidConfigurationException; -import org.bukkit.configuration.file.YamlConfiguration; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import java.util.Collections; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; - -public class YamlUserManager extends YamlConfiguration implements UserManager { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private final ConcurrentHashMap userData = new ConcurrentHashMap<>(); - - public YamlUserManager() { - - } - - @Override - public void load(UUID uuid) { - try { - File file = new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml"); - - if (!file.exists()) file.createNewFile(); - - load(file); - } catch (IOException | InvalidConfigurationException e) { - e.printStackTrace(); - } - } - - @Override - public void saveSingular(UUID uuid, boolean serverExit) { - // If user data empty return. - if (this.userData.isEmpty()) return; - - // Check if user data contains keys. - if (this.userData.containsKey(uuid)) { - // Remove user when done. - this.userData.remove(uuid); - - // Save the file then load the changes back in. - reload(uuid, serverExit); - } - } - - private void reload(UUID uuid, boolean serverExit) { - try { - File file = new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml"); - - save(file); - - if (!serverExit) load(uuid); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Override - public void save(boolean serverExit) { - // If user data empty return. - if (this.userData.isEmpty()) return; - - // If the player is not leaving, continue here as we are stopping the server or doing periodic save. - this.userData.forEach((id, user) -> { - //user.getKeys().forEach((crateMap, keys) -> set("users." + id + "." + crateMap, keys)); - - // Save the file then load the changes back in. - reload(id, serverExit); - }); - } - - @Override - public void convert(File file, UUID uuid, StorageType storageType) { - - } - - @Override - public void addAuction(UUID uuid) { - Player player = this.plugin.getServer().getPlayer(uuid); - } - - @Override - public File getFile(Path path, UUID uuid) { - return new File(this.plugin.getDataFolder() + "/users/" + uuid + ".yml"); - } - - @Override - public UserData getUser(UUID uuid) { - Player player = this.plugin.getServer().getPlayer(uuid); - - // Return with their user data. - return this.userData.get(uuid); - } - - @Override - public Map getUsers() { - return Collections.unmodifiableMap(this.userData); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/support/PlaceholderSupport.java b/paper/src/main/java/com/badbones69/crazyauctions/support/PlaceholderSupport.java deleted file mode 100644 index 3aef78e..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/support/PlaceholderSupport.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.badbones69.crazyauctions.support; - -import com.badbones69.crazyauctions.ApiManager; -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.config.types.PluginConfig; -import org.bukkit.plugin.java.JavaPlugin; - -public class PlaceholderSupport { - - private static final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - public static String setPlaceholders(String placeholder) { - placeholder = placeholder.replaceAll("\\{prefix}", ApiManager.getPluginConfig().getProperty(PluginConfig.COMMAND_PREFIX)); - - return placeholder; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/support/economy/Currency.java b/paper/src/main/java/com/badbones69/crazyauctions/support/economy/Currency.java deleted file mode 100644 index 046c464..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/support/economy/Currency.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.badbones69.crazyauctions.support.economy; - -/** - * Description: This event is fired when an item is added to an auction house. - */ -public enum Currency { - - VAULT("Vault"), - XP_LEVEL("XP_Level"), - XP_TOTAL("XP_Total"); - - private final String name; - - Currency(String name) { - this.name = name; - } - - /** - * Checks if it is a compatible currency. - * @param currency The currency name you are checking. - * @return True if it is supported and false if not. - */ - public static boolean isCurrency(String currency) { - for (Currency value : Currency.values()) { - if (currency.equalsIgnoreCase(value.getName())) return true; - } - - return false; - } - - /** - * Get a currency enum. - * @param currency The currency you want. - * @return The currency enum. - */ - public static Currency getCurrency(String currency) { - for (Currency value : Currency.values()) { - if (currency.equalsIgnoreCase(value.getName())) return value; - } - - return null; - } - - /** - * Get the name of the currency. - * @return The name of the currency. - */ - public String getName() { - return name; - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/support/economy/CurrencyAPI.java b/paper/src/main/java/com/badbones69/crazyauctions/support/economy/CurrencyAPI.java deleted file mode 100644 index ab92b20..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/support/economy/CurrencyAPI.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.badbones69.crazyauctions.support.economy; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; -import java.util.UUID; - -/** - * Description: Defines what currency to use. - */ -public class CurrencyAPI { - - // TODO() Add item support as a currency. - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - /** - * Get the amount that a player has from a specific currency. - * - * @param uuid - The uuid of the player. - * @param currency - The currency you wish to get from. - * @return amount that the player has of that currency. - */ - public int getCurrency(UUID uuid, Currency currency) { - try { - OfflinePlayer offlinePlayer = plugin.getServer().getOfflinePlayer(uuid); - Player player = plugin.getServer().getPlayer(uuid); - - switch (currency) { - case VAULT: //if (player != null) return (int) plugin.getVaultSupport().getVault().getBalance(player); - - case XP_LEVEL: if (player != null) return player.getLevel(); - - case XP_TOTAL: if (player != null) return getTotalExperience(player); - } - } catch (Exception | NoClassDefFoundError ignored) {} - return 0; - } - - /** - * Take an amount from a player's currency. - * - * @param uuid - The uuid of the player. - * @param currency - The currency you wish to use. - * @param amount - The amount you want to take. - */ - public void takeCurrency(UUID uuid, Currency currency, int amount) { - try { - Player player = plugin.getServer().getPlayer(uuid); - - switch (currency) { - //case VAULT: if (player != null) plugin.getVaultSupport().getVault().withdrawPlayer(player, amount); - case XP_LEVEL: if (player != null) player.setLevel(player.getLevel() - amount); - case XP_TOTAL: if (player != null) takeTotalExperience(player, amount); - } - } catch (Exception | NoClassDefFoundError ignored) {} - } - - /** - * Give an amount to a player's currency. - * - * @param uuid - The uuid of the player. - * @param currency - The currency you want to use. - * @param amount - The amount you are giving to the player. - */ - public void giveCurrency(UUID uuid, Currency currency, int amount) { - try { - Player player = plugin.getServer().getPlayer(uuid); - - switch (currency) { - //case VAULT: if (player != null) plugin.getVaultSupport().getVault().depositPlayer(player, amount); - case XP_LEVEL: if (player != null) player.setLevel(player.getLevel() + amount); - case XP_TOTAL: if (player != null) takeTotalExperience(player, -amount); - } - } catch (Exception | NoClassDefFoundError ignored) {} - } - - /** - * Checks if the player has enough of a currency. - * - * @param uuid - The uuid of the player. - * @param currency The currency you wish to check. - * @param cost The cost of the item you are checking. - * @return true if they have enough to buy it or false if they don't. - */ - public boolean canBuy(UUID uuid, Currency currency, int cost) { - return getCurrency(uuid, currency) >= cost; - } - - private void takeTotalExperience(Player player, int amount) { - int total = getTotalExperience(player) - amount; - player.setTotalExperience(0); - player.setTotalExperience(total); - player.setLevel(0); - player.setExp(0); - - while (total > player.getExpToLevel()) { - total -= player.getExpToLevel(); - player.setLevel(player.getLevel() + 1); - } - - float xp = (float) total / (float) player.getExpToLevel(); - player.setExp(xp); - } - - private int getTotalExperience(Player player) { // https://www.spigotmc.org/threads/72804 - int experience; - int level = player.getLevel(); - - if (level >= 0 && level <= 15) { - experience = (int) Math.ceil(Math.pow(level, 2) + (6 * level)); - int requiredExperience = 2 * level + 7; - double currentExp = Double.parseDouble(Float.toString(player.getExp())); - experience += Math.ceil(currentExp * requiredExperience); - return experience; - } else if (level > 15 && level <= 30) { - experience = (int) Math.ceil((2.5 * Math.pow(level, 2) - (40.5 * level) + 360)); - int requiredExperience = 5 * level - 38; - double currentExp = Double.parseDouble(Float.toString(player.getExp())); - experience += Math.ceil(currentExp * requiredExperience); - return experience; - } else { - experience = (int) Math.ceil((4.5 * Math.pow(level, 2) - (162.5 * level) + 2220)); - int requiredExperience = 9 * level - 158; - double currentExp = Double.parseDouble(Float.toString(player.getExp())); - experience += Math.ceil(currentExp * requiredExperience); - return experience; - } - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/support/economy/vault/VaultSupport.java b/paper/src/main/java/com/badbones69/crazyauctions/support/economy/vault/VaultSupport.java deleted file mode 100644 index 3051a51..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/support/economy/vault/VaultSupport.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.badbones69.crazyauctions.support.economy.vault; - -import com.badbones69.crazyauctions.CrazyAuctions; -import net.milkbowl.vault.economy.Economy; -import org.bukkit.plugin.RegisteredServiceProvider; -import org.bukkit.plugin.java.JavaPlugin; - -/** - * Description: Vault support related code. - */ -public class VaultSupport { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - private Economy vault = null; - - public Economy getVault() { - return vault; - } - - public void loadVault() { - RegisteredServiceProvider serviceProvider = plugin.getServer().getServicesManager().getRegistration(Economy.class); - - if (serviceProvider != null) vault = serviceProvider.getProvider(); - } -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/utils/ItemUtils.java b/paper/src/main/java/com/badbones69/crazyauctions/utils/ItemUtils.java deleted file mode 100644 index 70219f4..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/utils/ItemUtils.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.badbones69.crazyauctions.utils; - -import com.badbones69.crazyauctions.CrazyAuctions; -import org.bukkit.plugin.java.JavaPlugin; - -public class ItemUtils { - - private final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - -} \ No newline at end of file diff --git a/paper/src/main/java/com/badbones69/crazyauctions/utils/misc/ColorUtils.java b/paper/src/main/java/com/badbones69/crazyauctions/utils/misc/ColorUtils.java deleted file mode 100644 index cd7a27f..0000000 --- a/paper/src/main/java/com/badbones69/crazyauctions/utils/misc/ColorUtils.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.badbones69.crazyauctions.utils.misc; - -import com.badbones69.crazyauctions.ApiManager; -import com.badbones69.crazyauctions.CrazyAuctions; -import com.badbones69.crazyauctions.config.types.PluginConfig; -import org.bukkit.plugin.java.JavaPlugin; - -public class ColorUtils { - - private static final CrazyAuctions plugin = JavaPlugin.getPlugin(CrazyAuctions.class); - - public static String getPrefix() { - return ApiManager.getPluginConfig().getProperty(PluginConfig.COMMAND_PREFIX); - } -} \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..baa1d63 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,14 @@ +pluginManagement { + repositories { + + maven { url = 'https://repo.papermc.io/repository/maven-public/' } + + gradlePluginPortal() + mavenCentral() + } +} + +rootProject.name = 'CrazyAuctions' + +include 'common' +include 'paper' \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index 0ee9fbb..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1,16 +0,0 @@ -pluginManagement { - repositories { - maven("https://maven.fabricmc.net/") - - maven("https://maven.minecraftforge.net/") - - maven("https://repo.papermc.io/repository/maven-public/") - - gradlePluginPortal() - mavenCentral() - } -} - -rootProject.name = "CrazyAuctions" - -include("core", "paper") \ No newline at end of file