diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit new file mode 100644 index 0000000000..c3aaab4bb0 --- /dev/null +++ b/.git-hooks/pre-commit @@ -0,0 +1,49 @@ +#!/bin/bash + +echo "[pre-commit check]" + +if ! [ -x "$(command -v mvn)" ]; then + echo -e 'Maven are not installed!' + echo + echo 'Please visit following site to download latest maven:' + echo + echo " https://maven.apache.org/download.cgi" + echo + echo 'If you are sure that you have installed maven,' + echo 'Please check whether your environment variables is being set properly.' + exit 1 +fi + +spotless() { + if [ ! -e "mvn" ]; then + return 0 + fi + + CHANGED_FILES="$(git --no-pager diff --name-status --no-color --cached | awk '$1 != "D" && $NF ~ /\.xml?$/ { print $NF }')" + + if [ -z "$CHANGED_FILES" ]; then + echo "No staged files." + return 0 + fi + + echo '[pre-commit] Executing Maven spotlessCheck before commit' + + git stash --quiet --keep-index + + mvn -B spotless:check + + RESULT=$? + + git stash pop -q + + if [ "$RESULT" -ne "0" ]; then + echo -e "spotlessCheck failed..." + echo -e 'You can try "./mvn spotless:apply" to apply auto-fixes.' + fi + + return $RESULT +} + +if ! spotless; then + exit 1 +fi \ No newline at end of file diff --git a/.github/workflows/maven.yml b/.github/workflows/build-ci.yml similarity index 73% rename from .github/workflows/maven.yml rename to .github/workflows/build-ci.yml index 9cac6b9503..6fd685b6df 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/build-ci.yml @@ -1,7 +1,7 @@ # This workflow will build a Java project with Maven # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven -name: Slimefun Build Test +name: Slimefun Builder on: push: @@ -10,11 +10,6 @@ on: paths: - 'src/**' - 'pom.xml' - pull_request: - paths: - - '.github/workflows/**' - - 'src/**' - - 'pom.xml' workflow_dispatch: jobs: @@ -28,21 +23,24 @@ jobs: java-version: 17 java-package: jdk architecture: x64 - - run: mvn -B test --file pom.xml --errors + - name: Codestyle Check + run: mvn -B spotless:check -s $GITHUB_WORKSPACE/settings.xml --file pom.xml --errors + - name: Build Slimefun + run: mvn -B package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml --errors - uses: actions/cache@v2 - if: github.event_name != 'pull_request' + name: Cache dependencies with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} restore-keys: ${{ runner.os }}-m2 - uses: actions/upload-artifact@v2 - if: github.event_name != 'pull_request' + name: Upload Beta artifact with: - name: Slimefun.jar + name: Slimefun Beta Build path: staging - name: Automatic Releases uses: marvinpinto/action-automatic-releases@v1.2.1 - if: github.event_name != 'pull_request' && github.ref_name == 'master' + if: github.ref_name == 'master' with: repo_token: "${{ secrets.GITHUB_TOKEN }}" automatic_release_tag: "exp" diff --git a/.github/workflows/dev-release.yml b/.github/workflows/dev-ci.yml similarity index 67% rename from .github/workflows/dev-release.yml rename to .github/workflows/dev-ci.yml index 41b6d72147..1b32ab1a0d 100644 --- a/.github/workflows/dev-release.yml +++ b/.github/workflows/dev-ci.yml @@ -1,54 +1,54 @@ -# This workflow will build a Java project with Maven -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven - -name: Slimefun DEV - -on: - push: - branches: - - dev - paths: - - 'src/**' - - 'pom.xml' - workflow_dispatch: - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - distribution: 'zulu' - java-version: 17 - java-package: jdk - architecture: x64 - cache: maven - server-id: github - settings-path: ${{ github.workspace }} - - name: Build Slimefun - if: github.event_name != 'pull_request' - run: mvn -B package --file pom.xml --errors - - name: Publish Slimefun - if: github.event_name != 'pull_request' - run: mvn deploy -s $GITHUB_WORKSPACE/settings.xml --file pom-github-package.xml --errors - env: - GITHUB_TOKEN: ${{ github.token }} - - name: Mask Output - if: github.event_name != 'pull_request' - run: | - echo "::add-mask::$CF_API_TOKEN" - env: - CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} - - name: Find build artifact filename - if: github.event_name != 'pull_request' - run: | - cd target && FILENAME=$(find . -maxdepth 1 -mindepth 1 -name "Slimefun-*" | cut -d'/' -f 2) - echo "slimefun-artifact-name=$FILENAME" >> "$GITHUB_ENV" - cd .. - - name: Upload Build - if: github.event_name != 'pull_request' - uses: cloudflare/wrangler-action@2.0.0 - with: - apiToken: ${{ secrets.CF_API_TOKEN }} - command: "r2 object put slimefun-dev/${{ env.slimefun-artifact-name }} --file=./target/${{ env.slimefun-artifact-name }} --content-type=application/java-archive" +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Slimefun DEV + +on: + push: + branches: + - dev + paths: + - 'src/**' + - 'pom.xml' + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: 17 + java-package: jdk + architecture: x64 + cache: maven + - name: Codestyle check + run: mvn -B spotless:check --file pom.xml --errors + - name: Build Slimefun + run: mvn -B package -s $GITHUB_WORKSPACE/settings.xml --file pom.xml --errors + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Publish Slimefun + run: mvn -B deploy --file pom.xml --errors + env: + GITHUB_TOKEN: ${{ github.token }} + - name: Mask Output + run: | + echo "::add-mask::$CF_API_TOKEN" + env: + CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }} + - name: Get build artifact filename + run: | + cd target && FILENAME=$(find . -maxdepth 1 -mindepth 1 -name "slimefun-*" | cut -d'/' -f 2) + echo "slimefun-artifact-name=$FILENAME" >> "$GITHUB_ENV" + cd .. + - name: Upload Build to R2 + uses: cloudflare/wrangler-action@2.0.0 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + command: "r2 object put slimefun-dev/${{ env.slimefun-artifact-name }} --file=./target/${{ env.slimefun-artifact-name }} --content-type=application/java-archive" diff --git a/.github/workflows/package-maintainer.yml b/.github/workflows/package-maintainer.yml new file mode 100644 index 0000000000..f796c0d4ed --- /dev/null +++ b/.github/workflows/package-maintainer.yml @@ -0,0 +1,16 @@ +name: Package Maintainer + +on: + workflow_dispatch: + schedule: + - cron: '0 17 * * *' + +jobs: + delete-package-versions: + runs-on: ubuntu-latest + steps: + - uses: actions/delete-package-versions@v4 + with: + package-name: 'com.github.slimefun.slimefun' + package-type: 'maven' + min-versions-to-keep: 5 \ No newline at end of file diff --git a/.github/workflows/pr-checker.yml b/.github/workflows/pr-checker.yml new file mode 100644 index 0000000000..b8ae3998f1 --- /dev/null +++ b/.github/workflows/pr-checker.yml @@ -0,0 +1,25 @@ +# This workflow will build a Java project with Maven +# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven + +name: Pull Request Checker + +on: + pull_request: + paths: + - '.github/workflows/**' + - 'src/**' + - 'pom.xml' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-java@v2 + with: + distribution: 'zulu' + java-version: 17 + java-package: jdk + architecture: x64 + - name: Codestyle Check + run: mvn -B spotless:check build -s $GITHUB_WORKSPACE/settings.xml --file pom.xml --errors \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cf64d60236..08f8025bfd 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,8 +12,6 @@ > > 例如一个添加了新功能的提交应为 feat(item): add new item to Slimefun -此外, 推荐你使用 [gitmoji](https://gitmoji.dev/) 规范,但并不强制你使用。 - 如果你提交的代码中解决或处理了 Issue 中的问题,请你在主提交消息外显式声明。 > 如 resolves #114514, fix #114514 等 @@ -24,13 +22,16 @@ # 代码规范 -**!! 本项目使用空格缩进 !!** +**!! 本项目使用 4 空格缩进 !!** 请不要过度缩减代码长度, 空格少了 Slimefun 也不会因此跑得更快. +我们使用了 Spotless 作为代码格式化工具,你可以直接使用 `mvn spotless:check spotless:apply` 来自动格式化你的代码。 + 如果你希望你的代码被合并至官方, 请遵守 Slimefun 主仓库的 [提交规范](https://github.com/Slimefun/Slimefun4/blob/master/CONTRIBUTING.md) # 提交代码类型 + 你提交的代码可以是修复、新增内容和 API。 -下游代码现在支持提交 API 相关代码,开发者们可以通过 jitpack 依赖汉化版的 Slimefun。 \ No newline at end of file +下游代码现在支持提交 API 相关代码,开发者们可以通过 jitpack/GitHub Package 依赖汉化版的 Slimefun。 \ No newline at end of file diff --git a/pom-github-package.xml b/pom-github-package.xml deleted file mode 100644 index c3938cf7c5..0000000000 --- a/pom-github-package.xml +++ /dev/null @@ -1,436 +0,0 @@ - - - - 4.0.0 - com.github.slimefun - slimefun - - - - 5.0 - 2013 - jar - - - Slimefun is a Spigot/Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items - and recipes to your Minecraft Server. - - https://github.com/Slimefun/Slimefun4 - - - - UTF-8 - - - 16 - 16 - - - 1.20 - https://hub.spigotmc.org/javadocs/spigot/ - - - - - GitHub Issues - https://github.com/Slimefun/Slimefun4/issues - - - - - github - GitHub StarWishsama Apache Maven Packages - https://maven.pkg.github.com/StarWishsama/Slimefun-Secret - - - - - - - GNU General Public License v3.0 - https://github.com/Slimefun/Slimefun4/blob/master/LICENSE - repo - - - - - - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots - - - - paper-repo - https://repo.papermc.io/repository/maven-public/ - - - - jitpack.io - https://jitpack.io - - - - worldedit-repo - https://maven.enginehub.org/repo/ - - - - placeholderapi-repo - https://repo.extendedclip.com/content/repositories/placeholderapi - - - - mcmmo-repo - https://nexus.neetgames.com/repository/maven-public - - - - walshy-public - https://repo.walshy.dev/public - - - - codemc-repo - https://repo.codemc.io/repository/maven-public/ - - - - - - ${project.basedir}/src/main/java - - - clean package - - - ${project.name}-${project.version} - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.11.0 - - - - - - **/package-info.java - - 16 - 16 - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.5.0 - - - - - - io.github.bakedlibs.dough - io.github.thebusybiscuit.slimefun4.libraries.dough - - - io.papermc.lib - io.github.thebusybiscuit.slimefun4.libraries.paperlib - - - kong.unirest - io.github.thebusybiscuit.slimefun4.libraries.unirest - - - org.apache.commons.lang - io.github.thebusybiscuit.slimefun4.libraries.commons.lang - - - net.guizhanss.guizhanlib - io.github.thebusybiscuit.slimefun4.libraries.guizhanlib - - - com.zaxxer.hikari - io.github.thebusybiscuit.slimefun4.libraries.hikari - - - - - - - *:* - - META-INF/* - - - - - - - - package - - shade - - - - - - - - - - - ${basedir}/src/main/resources - true - - - plugin.yml - config.yml - item-models.yml - profile-storage.yml - block-storage.yml - - wiki.json - languages/translators.json - - tags/*.json - biome-maps/*.json - - languages/**/*.yml - - - - - - ${basedir} - false - - - LICENSE - - - - - - - - - org.spigotmc - spigot-api - ${spigot.version}-R0.1-SNAPSHOT - provided - - - - - com.google.code.findbugs - jsr305 - 3.0.2 - provided - - - - - com.github.StarWishsama.dough - dough-api - 9e25b14cb7 - compile - - - io.papermc - paperlib - 1.0.8 - compile - - - com.konghq - unirest-java - 3.14.5 - compile - - - - - com.google.code.gson - gson - - - - - com.zaxxer - HikariCP - 5.0.1 - compile - - - org.postgresql - postgresql - 42.6.0 - compile - - - - - com.sk89q.worldedit - worldedit-core - 7.2.15 - provided - - - - - * - * - - - - - com.sk89q.worldedit - worldedit-bukkit - 7.2.15 - provided - - - - - * - * - - - - - com.gmail.nossr50.mcMMO - mcMMO - 2.1.222 - provided - - - - - * - * - - - - - me.clip - placeholderapi - 2.11.3 - provided - - - - - * - * - - - - - me.minebuilders - clearlag-core - 3.1.6 - provided - - - - - * - * - - - - - com.github.LoneDev6 - itemsadder-api - 3.4.1-r4 - provided - - - - - * - * - - - - - net.imprex - orebfuscator-api - 5.3.0 - provided - - - - * - * - - - - - - com.github.MilkBowl - VaultAPI - 1.7.1 - provided - - - - * - * - - - - - org.maxgamer - QuickShop - 5.1.0.9 - provided - - - - * - * - - - - - - - commons-lang - commons-lang - 2.6 - compile - - - - com.github.Xzavier0722 - SlimefunCompLib - b7a2bd8 - compile - - - - - net.guizhanss - GuizhanLib-common - 1.3.0 - compile - - - net.guizhanss - GuizhanLib-updater - 1.3.0 - compile - - - diff --git a/pom.xml b/pom.xml index d5fa45622a..7adbf8c0d7 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ 4.0.0 com.github.slimefun - Slimefun + slimefun @@ -36,6 +36,14 @@ https://github.com/Slimefun/Slimefun4/issues + + + github + GitHub StarWishsama Apache Maven Packages + https://maven.pkg.github.com/StarWishsama/Slimefun-Secret + + + @@ -173,6 +181,23 @@ + + + com.diffplug.spotless + spotless-maven-plugin + 2.40.0 + + + + 2.38.0 + + + + + + + + @@ -230,9 +255,9 @@ - com.github.StarWishsama.dough + io.github.baked-libs dough-api - 9e25b14cb7 + 1.3.1-SNAPSHOT compile diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000000..8ff15a6857 --- /dev/null +++ b/settings.xml @@ -0,0 +1,36 @@ + + + + github + + + + + github + + + central + https://repo1.maven.org/maven2 + + + dough + https://maven.pkg.github.com/StarWishsama/dough + + true + + + + + + + + + dough + StarWishsama + ${env.GITHUB_TOKEN} + + + \ No newline at end of file diff --git a/src/main/java/city/norain/slimefun4/EnvironmentChecker.java b/src/main/java/city/norain/slimefun4/EnvironmentChecker.java index 40a9b61b26..b3318d53b7 100644 --- a/src/main/java/city/norain/slimefun4/EnvironmentChecker.java +++ b/src/main/java/city/norain/slimefun4/EnvironmentChecker.java @@ -8,24 +8,44 @@ import org.bukkit.Bukkit; class EnvironmentChecker { - private static final List UNSUPPORTED_PLUGINS = List.of("BedrockTechnology", "SlimefunFix", "SlimefunBugFixer", "Slimefunbookfix", "MiraiMC"); + private static final List UNSUPPORTED_PLUGINS = + List.of("BedrockTechnology", "SlimefunFix", "SlimefunBugFixer", "Slimefunbookfix", "MiraiMC"); static boolean checkIncompatiblePlugins(@Nonnull Slimefun sf, @Nonnull Logger logger) { - for (String name : UNSUPPORTED_PLUGINS) { - if (sf.getServer().getPluginManager().getPlugin(name) != null) { - logger.log(Level.WARNING, "检测到安装了 {0}, 该插件已不再兼容新版 Slimefun, 可能会带来不良效果!", name); - Bukkit.getPluginManager().disablePlugin(sf); - return true; - } + List plugins = UNSUPPORTED_PLUGINS.stream() + .filter(name -> sf.getServer().getPluginManager().getPlugin(name) != null) + .toList(); + + if (plugins.isEmpty()) { + return false; } - return false; + printBorder(logger); + logger.log(Level.WARNING, ""); + logger.log(Level.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + logger.log(Level.WARNING, "检测到不兼容的插件, 已自动禁用 Slimefun!"); + logger.log(Level.WARNING, "插件列表: ", String.join(", ", plugins)); + logger.log(Level.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + logger.log(Level.WARNING, ""); + printBorder(logger); + Bukkit.getPluginManager().disablePlugin(sf); + + return true; } static boolean checkHybridServer(@Nonnull Slimefun sf, @Nonnull Logger logger) { try { Class.forName("net.minecraftforge.common.MinecraftForge"); + Class.forName("net.fabricmc.loader.impl.launch.server.FabricServerLauncher"); + + printBorder(logger); + logger.log(Level.WARNING, ""); + logger.log(Level.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); logger.log(Level.WARNING, "检测到正在使用混合端, Slimefun 将会被禁用!"); + logger.log(Level.WARNING, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"); + logger.log(Level.WARNING, ""); + printBorder(logger); + Bukkit.getPluginManager().disablePlugin(sf); return true; @@ -35,11 +55,19 @@ static boolean checkHybridServer(@Nonnull Slimefun sf, @Nonnull Logger logger) { } static void scheduleSlimeGlueCheck(@Nonnull Slimefun sf, @Nonnull Logger logger) { - Bukkit.getScheduler().runTaskLater(sf, () -> { - if (Bukkit.getPluginManager().getPlugin("SlimeGlue") == null) { - logger.log(Level.WARNING, "检测到没有安装 SlimeGlue (粘液胶), 你将缺失对一些插件的额外保护检查!"); - logger.log(Level.WARNING, "下载: https://github.com/Xzavier0722/SlimeGlue"); - } - }, 300); // 15s + Bukkit.getScheduler() + .runTaskLater( + sf, + () -> { + if (Bukkit.getPluginManager().getPlugin("SlimeGlue") == null) { + logger.log(Level.WARNING, "检测到没有安装 SlimeGlue (粘液胶), 你将缺失对一些插件的额外保护检查!"); + logger.log(Level.WARNING, "下载: https://github.com/Xzavier0722/SlimeGlue"); + } + }, + 300); // 15s + } + + private static void printBorder(@Nonnull Logger logger) { + logger.log(Level.WARNING, "#######################################################"); } } diff --git a/src/main/java/city/norain/slimefun4/listener/SlimefunMigrateListener.java b/src/main/java/city/norain/slimefun4/listener/SlimefunMigrateListener.java index 8b2683607f..3756299cc5 100644 --- a/src/main/java/city/norain/slimefun4/listener/SlimefunMigrateListener.java +++ b/src/main/java/city/norain/slimefun4/listener/SlimefunMigrateListener.java @@ -15,7 +15,7 @@ public void onPlayerJoin(PlayerJoinEvent e) { var p = e.getPlayer(); if ((PlayerProfileMigrator.getInstance().hasOldData() - || BlockStorageMigrator.getInstance().hasOldData()) + || BlockStorageMigrator.getInstance().hasOldData()) && p.hasPermission("slimefun.command.migrate")) { p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&c检测到使用文件储存的旧数据, 请使用 /sf migrate 迁移旧数据至数据库!")); } diff --git a/src/main/java/city/norain/slimefun4/utils/InventoryUtil.java b/src/main/java/city/norain/slimefun4/utils/InventoryUtil.java index 8a776e403e..41414bcf7b 100644 --- a/src/main/java/city/norain/slimefun4/utils/InventoryUtil.java +++ b/src/main/java/city/norain/slimefun4/utils/InventoryUtil.java @@ -1,12 +1,11 @@ package city.norain.slimefun4.utils; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.LinkedList; import org.bukkit.Bukkit; import org.bukkit.entity.HumanEntity; import org.bukkit.inventory.Inventory; -import java.util.LinkedList; - public class InventoryUtil { /** * Close inventory for all viewers. diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/ChestInventoryParser.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/ChestInventoryParser.java index 9d2432b071..655864de23 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/ChestInventoryParser.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/ChestInventoryParser.java @@ -3,12 +3,11 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - import java.util.Collection; import java.util.Map; import java.util.function.Predicate; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; /** * @@ -30,7 +29,10 @@ public boolean canOutput(ItemStack item) { } @Override - public boolean matchRecipe(AbstractAutoCrafter crafter, Collection> recipe, Map itemQuantities) { + public boolean matchRecipe( + AbstractAutoCrafter crafter, + Collection> recipe, + Map itemQuantities) { for (Predicate predicate : recipe) { // Check if any Item matches the Predicate if (!crafter.matchesAny(inv, itemQuantities, predicate)) { @@ -69,5 +71,4 @@ private boolean isFit(ItemStack item) { } return false; } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractable.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractable.java index aeb64a50d4..21a966c4b4 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractable.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractable.java @@ -1,12 +1,11 @@ package com.xzavier0722.mc.plugin.slimefun4.autocrafter; import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; - import java.util.Collection; import java.util.Map; import java.util.function.Predicate; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; /** * @@ -32,7 +31,8 @@ public interface CrafterInteractable { * @param itemQuantities: the item's slot and amount after consume. * @return true if all matched, else false. */ - boolean matchRecipe(AbstractAutoCrafter crafter, Collection> recipe, Map itemQuantities); + boolean matchRecipe( + AbstractAutoCrafter crafter, Collection> recipe, Map itemQuantities); ItemStack getItem(int slot); @@ -46,6 +46,4 @@ public interface CrafterInteractable { * @param count: amount of different item. */ default void setIngredientCount(Block b, int count) {} - - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorHandler.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorHandler.java index 0d2eae9364..6b4e9fe5fc 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorHandler.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorHandler.java @@ -12,5 +12,4 @@ public interface CrafterInteractorHandler { CrafterInteractable getInteractor(BlockMenu menu); - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorManager.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorManager.java index a76e8da84e..d671483d64 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorManager.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterInteractorManager.java @@ -1,10 +1,9 @@ package com.xzavier0722.mc.plugin.slimefun4.autocrafter; import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; -import org.bukkit.block.Block; - import java.util.HashMap; import java.util.Map; +import org.bukkit.block.Block; /** * @@ -28,7 +27,7 @@ public class CrafterInteractorManager { * @see CrafterInteractorHandler */ public static void register(String id, CrafterInteractorHandler handler) { - handlers.put(id,handler); + handlers.put(id, handler); } public static CrafterInteractorHandler getHandler(String id) { @@ -48,5 +47,4 @@ public static boolean hasInterator(Block b) { var blockData = StorageCacheUtils.getBlock(b.getLocation()); return blockData != null && handlers.containsKey(blockData.getSfId()); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPort.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPort.java index fdb71fd720..16131a76e7 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPort.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPort.java @@ -11,6 +11,8 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; +import java.util.List; +import javax.annotation.Nonnull; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; @@ -25,12 +27,12 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import javax.annotation.Nonnull; -import java.util.List; - public class CrafterSmartPort extends SlimefunItem { - public static final int[] INPUT_SLOTS = {0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 18, 19, 20, 21, 22, 23, 27, 28, 29, 30, 31, 32, 36, 37, 38, 39, 40, 41, 45, 46, 47, 48, 49, 50}; + public static final int[] INPUT_SLOTS = { + 0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 13, 14, 18, 19, 20, 21, 22, 23, 27, 28, 29, 30, 31, 32, 36, 37, 38, 39, 40, 41, + 45, 46, 47, 48, 49, 50 + }; public static final int[] OUTPUT_SLOTS = {7, 8, 16, 17, 25, 26, 34, 35, 43, 44, 52, 53}; public CrafterSmartPort(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -53,7 +55,8 @@ public boolean onClick(Player p, int slot, ItemStack cursor, ClickAction action) } @Override - public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { + public boolean onClick( + InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { return cursor == null || cursor.getType().isAir(); } }); @@ -63,7 +66,8 @@ public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack curs @Override public boolean canOpen(@Nonnull Block b, @Nonnull Player p) { return p.hasPermission("slimefun.inventory.bypass") - || Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK); + || Slimefun.getProtectionManager() + .hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK); } @Override @@ -91,7 +95,8 @@ public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportF int itemAmount = wrapper.getAmount(); for (int slot : INPUT_SLOTS) { ItemStack itemInSlot = menu.getItemInSlot(slot); - if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) && (itemAmount += itemInSlot.getAmount()) > amountLimit) { + if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) + && (itemAmount += itemInSlot.getAmount()) > amountLimit) { // Amount has reached the limited, just return. return new int[0]; } @@ -108,7 +113,8 @@ public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportF public void preRegister() { addItemHandler(new BlockBreakHandler(false, true) { @Override - public void onPlayerBreak(@Nonnull BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List drops) { + public void onPlayerBreak( + @Nonnull BlockBreakEvent e, @Nonnull ItemStack item, @Nonnull List drops) { BlockMenu inv = StorageCacheUtils.getMenu(e.getBlock().getLocation()); if (inv != null) { for (int slot : INPUT_SLOTS) { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPortParser.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPortParser.java index 3fbbbdf9ad..d77706791c 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPortParser.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/autocrafter/CrafterSmartPortParser.java @@ -4,15 +4,14 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.AbstractAutoCrafter; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; - import java.util.Collection; import java.util.Map; import java.util.function.Predicate; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; -public class CrafterSmartPortParser implements CrafterInteractable{ +public class CrafterSmartPortParser implements CrafterInteractable { BlockMenu inv; @@ -43,7 +42,10 @@ public boolean canOutput(ItemStack item) { } @Override - public boolean matchRecipe(AbstractAutoCrafter crafter, Collection> recipe, Map itemQuantities) { + public boolean matchRecipe( + AbstractAutoCrafter crafter, + Collection> recipe, + Map itemQuantities) { for (Predicate predicate : recipe) { // Check if any Item matches the Predicate if (!crafter.matchesAny(inv.toInventory(), itemQuantities, predicate)) { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/PlayerChatCatcher.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/PlayerChatCatcher.java index adff7a3e92..3c7a871991 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/PlayerChatCatcher.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/PlayerChatCatcher.java @@ -2,13 +2,12 @@ import com.xzavier0722.mc.plugin.slimefun4.chat.listener.PlayerChatListener; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import org.bukkit.Bukkit; - import java.util.HashMap; import java.util.Map; import java.util.Optional; import java.util.UUID; import java.util.function.Consumer; +import org.bukkit.Bukkit; public class PlayerChatCatcher { private final Map> catchers; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/listener/PlayerChatListener.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/listener/PlayerChatListener.java index acc9d60fbb..f8b4b72072 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/listener/PlayerChatListener.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/chat/listener/PlayerChatListener.java @@ -21,5 +21,4 @@ public void onChat(AsyncPlayerChatEvent e) { public void onLeave(PlayerQuitEvent e) { Slimefun.getChatCatcher().pollCatcher(e.getPlayer().getUniqueId()); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/IDataSourceAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/IDataSourceAdapter.java index 6eb2583149..4ff398e716 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/IDataSourceAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/IDataSourceAdapter.java @@ -3,17 +3,22 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; - import java.util.List; public interface IDataSourceAdapter { void prepare(T config); + void initStorage(DataType type); + void shutdown(); + void setData(RecordKey key, RecordSet item); + default List getData(RecordKey key) { return getData(key, false); } + List getData(RecordKey key, boolean distinct); + void deleteData(RecordKey key); } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlAdapter.java index 4bb5791d9a..18ae9ffb44 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlAdapter.java @@ -1,226 +1,315 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; -import java.util.List; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_SIZE; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_CHUNK; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_KEY; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_VALUE; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_ITEM; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_SLOT; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_LOCATION; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_NAME; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_UUID; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; - -public class MysqlAdapter extends SqlCommonAdapter { - @Override - public void initStorage(DataType type) { - switch (type) { - case PLAYER_PROFILE -> { - profileTable = SqlUtils.mapTable(DataScope.PLAYER_PROFILE, config.tablePrefix()); - researchTable = SqlUtils.mapTable(DataScope.PLAYER_RESEARCH, config.tablePrefix()); - backpackTable = SqlUtils.mapTable(DataScope.BACKPACK_PROFILE, config.tablePrefix()); - bpInvTable = SqlUtils.mapTable(DataScope.BACKPACK_INVENTORY, config.tablePrefix()); - createProfileTables(); - } - case BLOCK_STORAGE -> { - blockRecordTable = SqlUtils.mapTable(DataScope.BLOCK_RECORD, config.tablePrefix()); - blockDataTable = SqlUtils.mapTable(DataScope.BLOCK_DATA, config.tablePrefix()); - blockInvTable = SqlUtils.mapTable(DataScope.BLOCK_INVENTORY, config.tablePrefix()); - chunkDataTable = SqlUtils.mapTable(DataScope.CHUNK_DATA, config.tablePrefix()); - createBlockStorageTables(); - } - } - } - - @Override - public void setData(RecordKey key, RecordSet item) { - var data = item.getAll(); - var fields = data.keySet(); - var fieldStr = SqlUtils.buildFieldStr(fields); - if (fieldStr.isEmpty()) { - throw new IllegalArgumentException("No data provided in RecordSet."); - } - - var valStr = new StringBuilder(); - var flag = false; - for (var field : fields) { - if (flag) { - valStr.append(", "); - } else { - flag = true; - } - valStr.append(SqlUtils.toSqlValStr(field, data.get(field))); - } - - var updateFields = key.getFields(); - - if (!updateFields.isEmpty() && key.getConditions().isEmpty()) { - throw new IllegalArgumentException("Condition is required for update statement!"); - } - - executeSql( - "INSERT INTO " + mapTable(key.getScope()) + " (" + fieldStr.get() + ") " - + "VALUES (" + valStr + ")" - + (updateFields.isEmpty() ? "" : " ON DUPLICATE KEY UPDATE " - + String.join(", ", updateFields.stream().map(field -> { - var val = item.get(field); - if (val == null) { - throw new IllegalArgumentException("Cannot find value in RecordSet for the specific key: " + field); - } - return SqlUtils.buildKvStr(field, val); - }).toList()) - ) + ";" - ); - } - - @Override - public List getData(RecordKey key, boolean distinct) { - return executeQuery( - (distinct ? "SELECT DISTINCT " : "SELECT ") + SqlUtils.buildFieldStr(key.getFields()).orElse("*") - +" FROM " + mapTable(key.getScope()) - + SqlUtils.buildConditionStr(key.getConditions()) + ";" - ); - } - - @Override - public void deleteData(RecordKey key) { - executeSql("DELETE FROM " + mapTable(key.getScope()) + SqlUtils.buildConditionStr(key.getConditions()) + ";"); - } - - private void createProfileTables() { - createProfileTable(); - createResearchTable(); - createBackpackTable(); - createBackpackInventoryTable(); - } - - private void createBlockStorageTables() { - createBlockRecordTable(); - createBlockDataTable(); - createBlockInvTable(); - createChunkDataTable(); - } - - private void createProfileTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + profileTable + "(" - + FIELD_PLAYER_UUID + " CHAR(64) PRIMARY KEY NOT NULL, " - + FIELD_PLAYER_NAME + " CHAR(64) NOT NULL, " - + FIELD_BACKPACK_NUM + " INT UNSIGNED DEFAULT 0, " - + "INDEX index_player_name (" + FIELD_PLAYER_NAME + ")" - + ");" - ); - } - - private void createResearchTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + researchTable + "(" - + FIELD_PLAYER_UUID + " CHAR(64) NOT NULL, " - + FIELD_RESEARCH_KEY + " CHAR(64) NOT NULL, " - + "FOREIGN KEY (" + FIELD_PLAYER_UUID + ") " - + "REFERENCES " + profileTable + "(" + FIELD_PLAYER_UUID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "INDEX index_player_research (" + FIELD_PLAYER_UUID + ", " + FIELD_RESEARCH_KEY + ")" - + ");" - ); - } - - private void createBackpackTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + backpackTable + "(" - + FIELD_BACKPACK_ID + " CHAR(64) PRIMARY KEY NOT NULL, " - + FIELD_PLAYER_UUID + " CHAR(64) NOT NULL, " - + FIELD_BACKPACK_NUM + " INT UNSIGNED NOT NULL, " - + FIELD_BACKPACK_NAME + " CHAR(64) NULL, " - + FIELD_BACKPACK_SIZE + " TINYINT UNSIGNED NOT NULL, " - + "FOREIGN KEY (" + FIELD_PLAYER_UUID + ") " - + "REFERENCES " + profileTable + "(" + FIELD_PLAYER_UUID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "INDEX index_player_backpack (" + FIELD_PLAYER_UUID + ", " + FIELD_BACKPACK_NUM + ")" - + ");" - ); - } - - private void createBackpackInventoryTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + bpInvTable + "(" - + FIELD_BACKPACK_ID + " CHAR(64) NOT NULL, " - + FIELD_INVENTORY_SLOT + " TINYINT UNSIGNED NOT NULL, " - + FIELD_INVENTORY_ITEM + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_BACKPACK_ID + ") " - + "REFERENCES " + backpackTable + "(" + FIELD_BACKPACK_ID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_BACKPACK_ID + ", " + FIELD_INVENTORY_SLOT + ")" - + ");" - ); - } - - private void createBlockRecordTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + blockRecordTable + "(" - + FIELD_LOCATION + " CHAR(64) PRIMARY KEY NOT NULL, " - + FIELD_CHUNK + " CHAR(64) NOT NULL, " - + FIELD_SLIMEFUN_ID + " CHAR(64) NOT NULL, " - + "INDEX index_ticking (" + FIELD_CHUNK + ")" - + ");" - ); - } - - private void createBlockDataTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + blockDataTable + "(" - + FIELD_LOCATION + " CHAR(64) NOT NULL, " - + FIELD_DATA_KEY + " CHAR(64) NOT NULL, " - + FIELD_DATA_VALUE + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_LOCATION + ") " - + "REFERENCES " + blockRecordTable + "(" + FIELD_LOCATION + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_LOCATION + ", " + FIELD_DATA_KEY + ")" - + ");" - ); - } - - private void createChunkDataTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + chunkDataTable + "(" - + FIELD_CHUNK + " CHAR(64) NOT NULL, " - + FIELD_DATA_KEY + " CHAR(64) NOT NULL, " - + FIELD_DATA_VALUE + " TEXT NOT NULL, " - + "PRIMARY KEY (" + FIELD_CHUNK + ", " + FIELD_DATA_KEY + ")" - + ");" - ); - } - - private void createBlockInvTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + blockInvTable + "(" - + FIELD_LOCATION + " CHAR(64) NOT NULL, " - + FIELD_INVENTORY_SLOT + " TINYINT UNSIGNED NOT NULL, " - + FIELD_INVENTORY_ITEM + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_LOCATION + ") " - + "REFERENCES " + blockRecordTable + "(" + FIELD_LOCATION + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_LOCATION + ", " + FIELD_INVENTORY_SLOT + ")" - + ");" - ); - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql; + +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_SIZE; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_CHUNK; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_KEY; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_VALUE; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_ITEM; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_SLOT; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_LOCATION; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_NAME; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_UUID; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; +import java.util.List; + +public class MysqlAdapter extends SqlCommonAdapter { + @Override + public void initStorage(DataType type) { + switch (type) { + case PLAYER_PROFILE -> { + profileTable = SqlUtils.mapTable(DataScope.PLAYER_PROFILE, config.tablePrefix()); + researchTable = SqlUtils.mapTable(DataScope.PLAYER_RESEARCH, config.tablePrefix()); + backpackTable = SqlUtils.mapTable(DataScope.BACKPACK_PROFILE, config.tablePrefix()); + bpInvTable = SqlUtils.mapTable(DataScope.BACKPACK_INVENTORY, config.tablePrefix()); + createProfileTables(); + } + case BLOCK_STORAGE -> { + blockRecordTable = SqlUtils.mapTable(DataScope.BLOCK_RECORD, config.tablePrefix()); + blockDataTable = SqlUtils.mapTable(DataScope.BLOCK_DATA, config.tablePrefix()); + blockInvTable = SqlUtils.mapTable(DataScope.BLOCK_INVENTORY, config.tablePrefix()); + chunkDataTable = SqlUtils.mapTable(DataScope.CHUNK_DATA, config.tablePrefix()); + createBlockStorageTables(); + } + } + } + + @Override + public void setData(RecordKey key, RecordSet item) { + var data = item.getAll(); + var fields = data.keySet(); + var fieldStr = SqlUtils.buildFieldStr(fields); + if (fieldStr.isEmpty()) { + throw new IllegalArgumentException("No data provided in RecordSet."); + } + + var valStr = new StringBuilder(); + var flag = false; + for (var field : fields) { + if (flag) { + valStr.append(", "); + } else { + flag = true; + } + valStr.append(SqlUtils.toSqlValStr(field, data.get(field))); + } + + var updateFields = key.getFields(); + + if (!updateFields.isEmpty() && key.getConditions().isEmpty()) { + throw new IllegalArgumentException("Condition is required for update statement!"); + } + + executeSql("INSERT INTO " + + mapTable(key.getScope()) + + " (" + + fieldStr.get() + + ") " + + "VALUES (" + + valStr + + ")" + + (updateFields.isEmpty() + ? "" + : " ON DUPLICATE KEY UPDATE " + + String.join( + ", ", + updateFields.stream() + .map(field -> { + var val = item.get(field); + if (val == null) { + throw new IllegalArgumentException( + "Cannot find value in RecordSet for the specific key: " + + field); + } + return SqlUtils.buildKvStr(field, val); + }) + .toList())) + + ";"); + } + + @Override + public List getData(RecordKey key, boolean distinct) { + return executeQuery((distinct ? "SELECT DISTINCT " : "SELECT ") + + SqlUtils.buildFieldStr(key.getFields()).orElse("*") + + " FROM " + + mapTable(key.getScope()) + + SqlUtils.buildConditionStr(key.getConditions()) + + ";"); + } + + @Override + public void deleteData(RecordKey key) { + executeSql("DELETE FROM " + mapTable(key.getScope()) + SqlUtils.buildConditionStr(key.getConditions()) + ";"); + } + + private void createProfileTables() { + createProfileTable(); + createResearchTable(); + createBackpackTable(); + createBackpackInventoryTable(); + } + + private void createBlockStorageTables() { + createBlockRecordTable(); + createBlockDataTable(); + createBlockInvTable(); + createChunkDataTable(); + } + + private void createProfileTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + profileTable + + "(" + + FIELD_PLAYER_UUID + + " CHAR(64) PRIMARY KEY NOT NULL, " + + FIELD_PLAYER_NAME + + " CHAR(64) NOT NULL, " + + FIELD_BACKPACK_NUM + + " INT UNSIGNED DEFAULT 0, " + + "INDEX index_player_name (" + + FIELD_PLAYER_NAME + + ")" + + ");"); + } + + private void createResearchTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + researchTable + + "(" + + FIELD_PLAYER_UUID + + " CHAR(64) NOT NULL, " + + FIELD_RESEARCH_KEY + + " CHAR(64) NOT NULL, " + + "FOREIGN KEY (" + + FIELD_PLAYER_UUID + + ") " + + "REFERENCES " + + profileTable + + "(" + + FIELD_PLAYER_UUID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "INDEX index_player_research (" + + FIELD_PLAYER_UUID + + ", " + + FIELD_RESEARCH_KEY + + ")" + + ");"); + } + + private void createBackpackTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + backpackTable + + "(" + + FIELD_BACKPACK_ID + + " CHAR(64) PRIMARY KEY NOT NULL, " + + FIELD_PLAYER_UUID + + " CHAR(64) NOT NULL, " + + FIELD_BACKPACK_NUM + + " INT UNSIGNED NOT NULL, " + + FIELD_BACKPACK_NAME + + " CHAR(64) NULL, " + + FIELD_BACKPACK_SIZE + + " TINYINT UNSIGNED NOT NULL, " + + "FOREIGN KEY (" + + FIELD_PLAYER_UUID + + ") " + + "REFERENCES " + + profileTable + + "(" + + FIELD_PLAYER_UUID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "INDEX index_player_backpack (" + + FIELD_PLAYER_UUID + + ", " + + FIELD_BACKPACK_NUM + + ")" + + ");"); + } + + private void createBackpackInventoryTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + bpInvTable + + "(" + + FIELD_BACKPACK_ID + + " CHAR(64) NOT NULL, " + + FIELD_INVENTORY_SLOT + + " TINYINT UNSIGNED NOT NULL, " + + FIELD_INVENTORY_ITEM + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_BACKPACK_ID + + ") " + + "REFERENCES " + + backpackTable + + "(" + + FIELD_BACKPACK_ID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_BACKPACK_ID + + ", " + + FIELD_INVENTORY_SLOT + + ")" + + ");"); + } + + private void createBlockRecordTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + blockRecordTable + + "(" + + FIELD_LOCATION + + " CHAR(64) PRIMARY KEY NOT NULL, " + + FIELD_CHUNK + + " CHAR(64) NOT NULL, " + + FIELD_SLIMEFUN_ID + + " CHAR(64) NOT NULL, " + + "INDEX index_ticking (" + + FIELD_CHUNK + + ")" + + ");"); + } + + private void createBlockDataTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + blockDataTable + + "(" + + FIELD_LOCATION + + " CHAR(64) NOT NULL, " + + FIELD_DATA_KEY + + " CHAR(64) NOT NULL, " + + FIELD_DATA_VALUE + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_LOCATION + + ") " + + "REFERENCES " + + blockRecordTable + + "(" + + FIELD_LOCATION + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_LOCATION + + ", " + + FIELD_DATA_KEY + + ")" + + ");"); + } + + private void createChunkDataTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + chunkDataTable + + "(" + + FIELD_CHUNK + + " CHAR(64) NOT NULL, " + + FIELD_DATA_KEY + + " CHAR(64) NOT NULL, " + + FIELD_DATA_VALUE + + " TEXT NOT NULL, " + + "PRIMARY KEY (" + + FIELD_CHUNK + + ", " + + FIELD_DATA_KEY + + ")" + + ");"); + } + + private void createBlockInvTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + blockInvTable + + "(" + + FIELD_LOCATION + + " CHAR(64) NOT NULL, " + + FIELD_INVENTORY_SLOT + + " TINYINT UNSIGNED NOT NULL, " + + FIELD_INVENTORY_ITEM + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_LOCATION + + ") " + + "REFERENCES " + + blockRecordTable + + "(" + + FIELD_LOCATION + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_LOCATION + + ", " + + FIELD_INVENTORY_SLOT + + ")" + + ");"); + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlConfig.java index 4cafeecf62..24110d85ac 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/mysql/MysqlConfig.java @@ -1,25 +1,27 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonConfig; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public class MysqlConfig extends SqlCommonConfig { - public MysqlConfig(String host, int port, String database, String tablePrefix, String user, String passwd, boolean useSsl, int maxConnection) { - super(host, port, database, tablePrefix, user, passwd, useSsl, maxConnection); - } - - @Override - public String jdbcUrl() { - return "jdbc:mysql://" - + host + ":" + port + "/" + database - + "?characterEncoding=utf8&useSSL=" + useSsl; - } - - @Override - public String driver() { - return "com.mysql.cj.jdbc.Driver"; - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonConfig; + +public class MysqlConfig extends SqlCommonConfig { + public MysqlConfig( + String host, + int port, + String database, + String tablePrefix, + String user, + String passwd, + boolean useSsl, + int maxConnection) { + super(host, port, database, tablePrefix, user, passwd, useSsl, maxConnection); + } + + @Override + public String jdbcUrl() { + return "jdbc:mysql://" + host + ":" + port + "/" + database + "?characterEncoding=utf8&useSSL=" + useSsl; + } + + @Override + public String driver() { + return "com.mysql.cj.jdbc.Driver"; + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlAdapter.java index 00805473b9..e1b550552e 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlAdapter.java @@ -1,237 +1,331 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; - -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_SIZE; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_CHUNK; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_KEY; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_VALUE; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_ITEM; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_SLOT; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_LOCATION; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_NAME; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_UUID; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; - -public class PostgreSqlAdapter extends SqlCommonAdapter { - @Override - public void initStorage(DataType type) { - switch (type) { - case PLAYER_PROFILE -> { - profileTable = SqlUtils.mapTable(DataScope.PLAYER_PROFILE, config.tablePrefix()); - researchTable = SqlUtils.mapTable(DataScope.PLAYER_RESEARCH, config.tablePrefix()); - backpackTable = SqlUtils.mapTable(DataScope.BACKPACK_PROFILE, config.tablePrefix()); - bpInvTable = SqlUtils.mapTable(DataScope.BACKPACK_INVENTORY, config.tablePrefix()); - createProfileTables(); - } - case BLOCK_STORAGE -> { - blockRecordTable = SqlUtils.mapTable(DataScope.BLOCK_RECORD, config.tablePrefix()); - blockDataTable = SqlUtils.mapTable(DataScope.BLOCK_DATA, config.tablePrefix()); - blockInvTable = SqlUtils.mapTable(DataScope.BLOCK_INVENTORY, config.tablePrefix()); - chunkDataTable = SqlUtils.mapTable(DataScope.CHUNK_DATA, config.tablePrefix()); - createBlockStorageTables(); - } - } - } - - @Override - public void setData(RecordKey key, RecordSet item) { - var data = item.getAll(); - var fields = data.keySet(); - var fieldStr = SqlUtils.buildFieldStr(fields); - if (fieldStr.isEmpty()) { - throw new IllegalArgumentException("No data provided in RecordSet."); - } - - var valStr = new StringBuilder(); - var flag = false; - for (var field : fields) { - if (flag) { - valStr.append(", "); - } else { - flag = true; - } - valStr.append(SqlUtils.toSqlValStr(field, data.get(field))); - } - - var updateFields = key.getFields(); - - if (!updateFields.isEmpty() && key.getConditions().isEmpty()) { - throw new IllegalArgumentException("Condition is required for update statement!"); - } - - var contrastStr = Arrays.stream(key.getScope().getPrimaryKeys()).map(SqlUtils::mapField).collect(Collectors.joining(", ")); - - executeSql( - "INSERT INTO " + mapTable(key.getScope()) + " (" + fieldStr.get() + ") " - + "VALUES (" + valStr + ")" - + (contrastStr.isEmpty() ? "" : " ON CONFLICT (" + contrastStr + ") " + (updateFields.isEmpty() ? "DO NOTHING" : "DO UPDATE SET " - + String.join(", ", updateFields.stream().map(field -> { - var val = item.get(field); - if (val == null) { - throw new IllegalArgumentException("Cannot find value in RecordSet for the specific key: " + field); - } - return SqlUtils.buildKvStr(field, val); - }).toList()) - )) + ";" - ); - } - - @Override - public List getData(RecordKey key, boolean distinct) { - return executeQuery( - (distinct ? "SELECT DISTINCT " : "SELECT ") + SqlUtils.buildFieldStr(key.getFields()).orElse("*") - + " FROM " + mapTable(key.getScope()) - + SqlUtils.buildConditionStr(key.getConditions()) + ";" - ); - } - - @Override - public void deleteData(RecordKey key) { - executeSql("DELETE FROM " + mapTable(key.getScope()) + SqlUtils.buildConditionStr(key.getConditions()) + ";"); - } - - - private void createProfileTables() { - createProfileTable(); - createResearchTable(); - createBackpackTable(); - createBackpackInventoryTable(); - } - - private void createBlockStorageTables() { - createBlockRecordTable(); - createBlockDataTable(); - createBlockInvTable(); - createChunkDataTable(); - } - - private void createProfileTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + profileTable + "(" - + FIELD_PLAYER_UUID + " VARCHAR(64) PRIMARY KEY NOT NULL, " - + FIELD_PLAYER_NAME + " VARCHAR(64) NOT NULL, " - + FIELD_BACKPACK_NUM + " INT DEFAULT 0" - + ");" - ); - - executeSql("CREATE INDEX IF NOT EXISTS index_player_name ON " + profileTable + " (" + FIELD_PLAYER_NAME + ");"); - } - - private void createResearchTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + researchTable + "(" - + FIELD_PLAYER_UUID + " VARCHAR(64) NOT NULL, " - + FIELD_RESEARCH_KEY + " VARCHAR(64) NOT NULL, " - + "FOREIGN KEY (" + FIELD_PLAYER_UUID + ") " - + "REFERENCES " + profileTable + "(" + FIELD_PLAYER_UUID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE" - + ");" - ); - - executeSql("CREATE INDEX IF NOT EXISTS index_player_research ON " + researchTable + " (" + FIELD_PLAYER_UUID + ", " + FIELD_RESEARCH_KEY + ");"); - } - - private void createBackpackTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + backpackTable + "(" - + FIELD_BACKPACK_ID + " VARCHAR(64) PRIMARY KEY NOT NULL, " - + FIELD_PLAYER_UUID + " VARCHAR(64) NOT NULL, " - + FIELD_BACKPACK_NUM + " INT NOT NULL, " - + FIELD_BACKPACK_NAME + " VARCHAR(64) NULL, " - + FIELD_BACKPACK_SIZE + " SMALLINT NOT NULL, " - + "FOREIGN KEY (" + FIELD_PLAYER_UUID + ") " - + "REFERENCES " + profileTable + "(" + FIELD_PLAYER_UUID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE" - + ");" - ); - - executeSql("CREATE INDEX IF NOT EXISTS index_player_backpack ON " + backpackTable + " (" + FIELD_PLAYER_UUID + ", " + FIELD_BACKPACK_NUM + ");"); - } - - private void createBackpackInventoryTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + bpInvTable + "(" - + FIELD_BACKPACK_ID + " VARCHAR(64) NOT NULL, " - + FIELD_INVENTORY_SLOT + " SMALLINT NOT NULL, " - + FIELD_INVENTORY_ITEM + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_BACKPACK_ID + ") " - + "REFERENCES " + backpackTable + "(" + FIELD_BACKPACK_ID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_BACKPACK_ID + ", " + FIELD_INVENTORY_SLOT + ")" - + ");" - ); - } - - private void createBlockRecordTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + blockRecordTable + "(" - + FIELD_LOCATION + " VARCHAR(64) PRIMARY KEY NOT NULL, " - + FIELD_CHUNK + " VARCHAR(64) NOT NULL, " - + FIELD_SLIMEFUN_ID + " VARCHAR(64) NOT NULL" - + ");" - ); - - executeSql("CREATE INDEX IF NOT EXISTS index_ticking ON " + blockRecordTable + " (" + FIELD_CHUNK + ");"); - } - - private void createBlockDataTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + blockDataTable + "(" - + FIELD_LOCATION + " VARCHAR(64) NOT NULL, " - + FIELD_DATA_KEY + " VARCHAR(64) NOT NULL, " - + FIELD_DATA_VALUE + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_LOCATION + ") " - + "REFERENCES " + blockRecordTable + "(" + FIELD_LOCATION + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_LOCATION + ", " + FIELD_DATA_KEY + ")" - + ");" - ); - } - - private void createChunkDataTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + chunkDataTable + "(" - + FIELD_CHUNK + " VARCHAR(64) NOT NULL, " - + FIELD_DATA_KEY + " VARCHAR(64) NOT NULL, " - + FIELD_DATA_VALUE + " TEXT NOT NULL, " - + "PRIMARY KEY (" + FIELD_CHUNK + ", " + FIELD_DATA_KEY + ")" - + ");" - ); - } - - private void createBlockInvTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + blockInvTable + "(" - + FIELD_LOCATION + " VARCHAR(64) NOT NULL, " - + FIELD_INVENTORY_SLOT + " SMALLINT NOT NULL, " - + FIELD_INVENTORY_ITEM + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_LOCATION + ") " - + "REFERENCES " + blockRecordTable + "(" + FIELD_LOCATION + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_LOCATION + ", " + FIELD_INVENTORY_SLOT + ")" - + ");" - ); - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql; + +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_SIZE; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_CHUNK; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_KEY; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_VALUE; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_ITEM; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_SLOT; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_LOCATION; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_NAME; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_UUID; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +public class PostgreSqlAdapter extends SqlCommonAdapter { + @Override + public void initStorage(DataType type) { + switch (type) { + case PLAYER_PROFILE -> { + profileTable = SqlUtils.mapTable(DataScope.PLAYER_PROFILE, config.tablePrefix()); + researchTable = SqlUtils.mapTable(DataScope.PLAYER_RESEARCH, config.tablePrefix()); + backpackTable = SqlUtils.mapTable(DataScope.BACKPACK_PROFILE, config.tablePrefix()); + bpInvTable = SqlUtils.mapTable(DataScope.BACKPACK_INVENTORY, config.tablePrefix()); + createProfileTables(); + } + case BLOCK_STORAGE -> { + blockRecordTable = SqlUtils.mapTable(DataScope.BLOCK_RECORD, config.tablePrefix()); + blockDataTable = SqlUtils.mapTable(DataScope.BLOCK_DATA, config.tablePrefix()); + blockInvTable = SqlUtils.mapTable(DataScope.BLOCK_INVENTORY, config.tablePrefix()); + chunkDataTable = SqlUtils.mapTable(DataScope.CHUNK_DATA, config.tablePrefix()); + createBlockStorageTables(); + } + } + } + + @Override + public void setData(RecordKey key, RecordSet item) { + var data = item.getAll(); + var fields = data.keySet(); + var fieldStr = SqlUtils.buildFieldStr(fields); + if (fieldStr.isEmpty()) { + throw new IllegalArgumentException("No data provided in RecordSet."); + } + + var valStr = new StringBuilder(); + var flag = false; + for (var field : fields) { + if (flag) { + valStr.append(", "); + } else { + flag = true; + } + valStr.append(SqlUtils.toSqlValStr(field, data.get(field))); + } + + var updateFields = key.getFields(); + + if (!updateFields.isEmpty() && key.getConditions().isEmpty()) { + throw new IllegalArgumentException("Condition is required for update statement!"); + } + + var contrastStr = Arrays.stream(key.getScope().getPrimaryKeys()) + .map(SqlUtils::mapField) + .collect(Collectors.joining(", ")); + + executeSql("INSERT INTO " + + mapTable(key.getScope()) + + " (" + + fieldStr.get() + + ") " + + "VALUES (" + + valStr + + ")" + + (contrastStr.isEmpty() + ? "" + : " ON CONFLICT (" + + contrastStr + + ") " + + (updateFields.isEmpty() + ? "DO NOTHING" + : "DO UPDATE SET " + + String.join( + ", ", + updateFields.stream() + .map(field -> { + var val = item.get(field); + if (val == null) { + throw new IllegalArgumentException( + "Cannot find value in RecordSet for the specific" + + " key: " + + field); + } + return SqlUtils.buildKvStr(field, val); + }) + .toList()))) + + ";"); + } + + @Override + public List getData(RecordKey key, boolean distinct) { + return executeQuery((distinct ? "SELECT DISTINCT " : "SELECT ") + + SqlUtils.buildFieldStr(key.getFields()).orElse("*") + + " FROM " + + mapTable(key.getScope()) + + SqlUtils.buildConditionStr(key.getConditions()) + + ";"); + } + + @Override + public void deleteData(RecordKey key) { + executeSql("DELETE FROM " + mapTable(key.getScope()) + SqlUtils.buildConditionStr(key.getConditions()) + ";"); + } + + private void createProfileTables() { + createProfileTable(); + createResearchTable(); + createBackpackTable(); + createBackpackInventoryTable(); + } + + private void createBlockStorageTables() { + createBlockRecordTable(); + createBlockDataTable(); + createBlockInvTable(); + createChunkDataTable(); + } + + private void createProfileTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + profileTable + + "(" + + FIELD_PLAYER_UUID + + " VARCHAR(64) PRIMARY KEY NOT NULL, " + + FIELD_PLAYER_NAME + + " VARCHAR(64) NOT NULL, " + + FIELD_BACKPACK_NUM + + " INT DEFAULT 0" + + ");"); + + executeSql("CREATE INDEX IF NOT EXISTS index_player_name ON " + profileTable + " (" + FIELD_PLAYER_NAME + ");"); + } + + private void createResearchTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + researchTable + + "(" + + FIELD_PLAYER_UUID + + " VARCHAR(64) NOT NULL, " + + FIELD_RESEARCH_KEY + + " VARCHAR(64) NOT NULL, " + + "FOREIGN KEY (" + + FIELD_PLAYER_UUID + + ") " + + "REFERENCES " + + profileTable + + "(" + + FIELD_PLAYER_UUID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE" + + ");"); + + executeSql("CREATE INDEX IF NOT EXISTS index_player_research ON " + + researchTable + + " (" + + FIELD_PLAYER_UUID + + ", " + + FIELD_RESEARCH_KEY + + ");"); + } + + private void createBackpackTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + backpackTable + + "(" + + FIELD_BACKPACK_ID + + " VARCHAR(64) PRIMARY KEY NOT NULL, " + + FIELD_PLAYER_UUID + + " VARCHAR(64) NOT NULL, " + + FIELD_BACKPACK_NUM + + " INT NOT NULL, " + + FIELD_BACKPACK_NAME + + " VARCHAR(64) NULL, " + + FIELD_BACKPACK_SIZE + + " SMALLINT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_PLAYER_UUID + + ") " + + "REFERENCES " + + profileTable + + "(" + + FIELD_PLAYER_UUID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE" + + ");"); + + executeSql("CREATE INDEX IF NOT EXISTS index_player_backpack ON " + + backpackTable + + " (" + + FIELD_PLAYER_UUID + + ", " + + FIELD_BACKPACK_NUM + + ");"); + } + + private void createBackpackInventoryTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + bpInvTable + + "(" + + FIELD_BACKPACK_ID + + " VARCHAR(64) NOT NULL, " + + FIELD_INVENTORY_SLOT + + " SMALLINT NOT NULL, " + + FIELD_INVENTORY_ITEM + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_BACKPACK_ID + + ") " + + "REFERENCES " + + backpackTable + + "(" + + FIELD_BACKPACK_ID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_BACKPACK_ID + + ", " + + FIELD_INVENTORY_SLOT + + ")" + + ");"); + } + + private void createBlockRecordTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + blockRecordTable + + "(" + + FIELD_LOCATION + + " VARCHAR(64) PRIMARY KEY NOT NULL, " + + FIELD_CHUNK + + " VARCHAR(64) NOT NULL, " + + FIELD_SLIMEFUN_ID + + " VARCHAR(64) NOT NULL" + + ");"); + + executeSql("CREATE INDEX IF NOT EXISTS index_ticking ON " + blockRecordTable + " (" + FIELD_CHUNK + ");"); + } + + private void createBlockDataTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + blockDataTable + + "(" + + FIELD_LOCATION + + " VARCHAR(64) NOT NULL, " + + FIELD_DATA_KEY + + " VARCHAR(64) NOT NULL, " + + FIELD_DATA_VALUE + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_LOCATION + + ") " + + "REFERENCES " + + blockRecordTable + + "(" + + FIELD_LOCATION + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_LOCATION + + ", " + + FIELD_DATA_KEY + + ")" + + ");"); + } + + private void createChunkDataTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + chunkDataTable + + "(" + + FIELD_CHUNK + + " VARCHAR(64) NOT NULL, " + + FIELD_DATA_KEY + + " VARCHAR(64) NOT NULL, " + + FIELD_DATA_VALUE + + " TEXT NOT NULL, " + + "PRIMARY KEY (" + + FIELD_CHUNK + + ", " + + FIELD_DATA_KEY + + ")" + + ");"); + } + + private void createBlockInvTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + blockInvTable + + "(" + + FIELD_LOCATION + + " VARCHAR(64) NOT NULL, " + + FIELD_INVENTORY_SLOT + + " SMALLINT NOT NULL, " + + FIELD_INVENTORY_ITEM + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_LOCATION + + ") " + + "REFERENCES " + + blockRecordTable + + "(" + + FIELD_LOCATION + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_LOCATION + + ", " + + FIELD_INVENTORY_SLOT + + ")" + + ");"); + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlConfig.java index 6c62b604af..070759463d 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/postgresql/PostgreSqlConfig.java @@ -1,25 +1,27 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonConfig; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public class PostgreSqlConfig extends SqlCommonConfig { - public PostgreSqlConfig(String host, int port, String database, String tablePrefix, String user, String passwd, boolean useSsl, int maxConnection) { - super(host, port, database, tablePrefix, user, passwd, useSsl, maxConnection); - } - - @Override - public String jdbcUrl() { - return "jdbc:postgresql://" - + host + ":" + port + "/" + database - + "?ssl=" + useSsl; - } - - @Override - public String driver() { - return "org.postgresql.Driver"; - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonConfig; + +public class PostgreSqlConfig extends SqlCommonConfig { + public PostgreSqlConfig( + String host, + int port, + String database, + String tablePrefix, + String user, + String passwd, + boolean useSsl, + int maxConnection) { + super(host, port, database, tablePrefix, user, passwd, useSsl, maxConnection); + } + + @Override + public String jdbcUrl() { + return "jdbc:postgresql://" + host + ":" + port + "/" + database + "?ssl=" + useSsl; + } + + @Override + public String driver() { + return "org.postgresql.Driver"; + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/ISqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/ISqlCommonConfig.java index 44f2925eab..8fc46a755a 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/ISqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/ISqlCommonConfig.java @@ -4,7 +4,8 @@ public interface ISqlCommonConfig { String driver(); + String jdbcUrl(); - HikariDataSource createDataSource(); + HikariDataSource createDataSource(); } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java index 8e88853c49..31b8001a0d 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlCommonConfig.java @@ -2,7 +2,6 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; - import java.util.Properties; import java.util.concurrent.TimeUnit; @@ -24,8 +23,7 @@ public SqlCommonConfig( String user, String passwd, boolean useSsl, - int maxConnection - ) { + int maxConnection) { this.host = host; this.port = port; this.database = database; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java index b788019a6a..d3ed2b8c23 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlcommon/SqlUtils.java @@ -1,21 +1,5 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.FieldKey; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.FieldMapper; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; -import io.github.bakedlibs.dough.collections.Pair; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import java.sql.Connection; -import java.sql.ResultSetMetaData; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Optional; -import java.util.Set; import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; @@ -39,9 +23,27 @@ import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.TABLE_NAME_PLAYER_PROFILE; import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.TABLE_NAME_PLAYER_RESEARCH; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.FieldKey; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.FieldMapper; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; +import io.github.bakedlibs.dough.collections.Pair; +import io.github.thebusybiscuit.slimefun4.core.debug.Debug; +import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; +import java.sql.Connection; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Optional; +import java.util.Set; + public class SqlUtils { private static final FieldMapper mapper; + static { var fieldMap = new HashMap(); fieldMap.put(FieldKey.PLAYER_UUID, FIELD_PLAYER_UUID); @@ -94,19 +96,21 @@ public static Optional buildFieldStr(Set fields) { if (fields.isEmpty()) { return Optional.empty(); } - return Optional.of(String.join(", ", fields.stream().map(SqlUtils::mapField).toList())); + return Optional.of( + String.join(", ", fields.stream().map(SqlUtils::mapField).toList())); } + public static String buildConditionStr(List> conditions) { if (conditions.isEmpty()) { return ""; } - return " WHERE " + String.join( - " AND ", - conditions.stream().map( - condition -> buildKvStr(condition.getFirstValue(), condition.getSecondValue()) - ).toList() - ); + return " WHERE " + + String.join( + " AND ", + conditions.stream() + .map(condition -> buildKvStr(condition.getFirstValue(), condition.getSecondValue())) + .toList()); } public static String buildKvStr(FieldKey key, String val) { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java index cbdc4706a2..fcc3f4de93 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteAdapter.java @@ -1,251 +1,325 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; - -import java.sql.SQLException; -import java.util.List; - -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_SIZE; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_CHUNK; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_KEY; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_VALUE; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_ITEM; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_SLOT; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_LOCATION; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_NAME; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_UUID; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; -import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; - -public class SqliteAdapter extends SqlCommonAdapter { - @Override - public void initStorage(DataType type) { - switch (type) { - case PLAYER_PROFILE -> createProfileTables(); - case BLOCK_STORAGE -> createBlockStorageTables(); - } - } - - @Override - public void setData(RecordKey key, RecordSet item) { - var data = item.getAll(); - var fields = data.keySet(); - var fieldStr = SqlUtils.buildFieldStr(fields); - if (fieldStr.isEmpty()) { - throw new IllegalArgumentException("No data provided in RecordSet."); - } - - var valStr = new StringBuilder(); - var flag = false; - for (var field : fields) { - if (flag) { - valStr.append(", "); - } else { - flag = true; - } - valStr.append(SqlUtils.toSqlValStr(field, data.get(field))); - } - - var updateFields = key.getFields(); - var table = SqlUtils.mapTable(key.getScope()); - - if (!updateFields.isEmpty()) { - if (key.getConditions().isEmpty()) { - throw new IllegalArgumentException("Condition is required for update statement!"); - } - - var row = executeUpdate( - "UPDATE " + table + " SET " - + String.join(", ", updateFields.stream().map(field -> { - var val = item.get(field); - if (val == null) { - throw new IllegalArgumentException("Cannot find value in RecordSet for the specific key: " + field); - } - return SqlUtils.buildKvStr(field, val); - }).toList()) + SqlUtils.buildConditionStr(key.getConditions()) + ";" - ); - if (row > 0) { - return; - } - } - - executeSql( - "INSERT OR IGNORE INTO " + table + " (" + fieldStr.get() + ") VALUES (" + valStr + ");" - ); - } - - @Override - public List getData(RecordKey key, boolean distinct) { - return executeQuery( - (distinct ? "SELECT DISTINCT " : "SELECT ") + SqlUtils.buildFieldStr(key.getFields()).orElse("*") - +" FROM " + SqlUtils.mapTable(key.getScope()) - + SqlUtils.buildConditionStr(key.getConditions()) + ";" - ); - } - - @Override - public void deleteData(RecordKey key) { - executeSql("DELETE FROM " + SqlUtils.mapTable(key.getScope()) + SqlUtils.buildConditionStr(key.getConditions()) + ";"); - } - - private void createProfileTables() { - createProfileTable(); - createResearchTable(); - createBackpackTable(); - createBackpackInvTable(); - } - - private void createBlockStorageTables() { - createBlockRecordTable(); - createBlockDataTable(); - createBlockInvTable(); - createChunkDataTable(); - } - - private void createProfileTable() { - var table = SqlUtils.mapTable(DataScope.PLAYER_PROFILE); - executeSql( - "CREATE TABLE IF NOT EXISTS " - + table + "(" - + FIELD_PLAYER_UUID + " TEXT PRIMARY KEY NOT NULL, " - + FIELD_PLAYER_NAME + " TEXT NOT NULL, " - + FIELD_BACKPACK_NUM + " INTEGER DEFAULT 0" - + ");" - ); - - executeSql( - "CREATE INDEX IF NOT EXISTS index_player_name ON " + table + " (" + FIELD_PLAYER_NAME + ");" - ); - } - - private void createResearchTable() { - var table = SqlUtils.mapTable(DataScope.PLAYER_RESEARCH); - executeSql( - "CREATE TABLE IF NOT EXISTS " - + table + "(" - + FIELD_PLAYER_UUID + " TEXT NOT NULL, " - + FIELD_RESEARCH_KEY + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_PLAYER_UUID + ") " - + "REFERENCES " + SqlUtils.mapTable(DataScope.PLAYER_PROFILE) + "(" + FIELD_PLAYER_UUID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE);" - ); - - executeSql( - "CREATE INDEX IF NOT EXISTS index_player_researches ON " + table + " (" + FIELD_PLAYER_UUID + ", " + FIELD_RESEARCH_KEY + ");" - ); - } - - private void createBackpackTable() { - var table = SqlUtils.mapTable(DataScope.BACKPACK_PROFILE); - executeSql( - "CREATE TABLE IF NOT EXISTS " - + table + "(" - + FIELD_BACKPACK_ID + " TEXT PRIMARY KEY NOT NULL, " - + FIELD_PLAYER_UUID + " TEXT NOT NULL, " - + FIELD_BACKPACK_NUM + " INTEGER NOT NULL, " - + FIELD_BACKPACK_NAME + " TEXT NULL, " - + FIELD_BACKPACK_SIZE + " INTEGER NOT NULL, " - + "FOREIGN KEY (" + FIELD_PLAYER_UUID + ") " - + "REFERENCES " + SqlUtils.mapTable(DataScope.PLAYER_PROFILE) + "(" + FIELD_PLAYER_UUID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE);" - ); - - executeSql( - "CREATE INDEX IF NOT EXISTS index_player_backpack ON " + table + " (" + FIELD_PLAYER_UUID + ", " + FIELD_BACKPACK_NUM + ");" - ); - } - - private void createBackpackInvTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + SqlUtils.mapTable(DataScope.BACKPACK_INVENTORY) + "(" - + FIELD_BACKPACK_ID + " TEXT NOT NULL, " - + FIELD_INVENTORY_SLOT + " INTEGER NOT NULL, " - + FIELD_INVENTORY_ITEM + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_BACKPACK_ID + ") " - + "REFERENCES " + SqlUtils.mapTable(DataScope.BACKPACK_PROFILE) + "(" + FIELD_BACKPACK_ID + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_BACKPACK_ID + ", " + FIELD_INVENTORY_SLOT + ")" - + ");" - ); - } - - - private void createBlockRecordTable() { - var table = SqlUtils.mapTable(DataScope.BLOCK_RECORD); - executeSql( - "CREATE TABLE IF NOT EXISTS " - + table + "(" - + FIELD_LOCATION + " TEXT PRIMARY KEY NOT NULL, " - + FIELD_CHUNK + " TEXT NOT NULL, " - + FIELD_SLIMEFUN_ID + " TEXT NOT NULL" - + ");" - ); - - executeSql( - "CREATE INDEX IF NOT EXISTS index_chunk ON " + table + "(" + FIELD_CHUNK + ");" - ); - } - - private void createBlockDataTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + SqlUtils.mapTable(DataScope.BLOCK_DATA) + "(" - + FIELD_LOCATION + " TEXT NOT NULL, " - + FIELD_DATA_KEY + " TEXT NOT NULL, " - + FIELD_DATA_VALUE + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_LOCATION + ") " - + "REFERENCES " + SqlUtils.mapTable(DataScope.BLOCK_RECORD) + "(" + FIELD_LOCATION + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_LOCATION + ", " + FIELD_DATA_KEY + ")" - + ");" - ); - } - - private void createChunkDataTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + SqlUtils.mapTable(DataScope.CHUNK_DATA) + "(" - + FIELD_CHUNK + " TEXT NOT NULL, " - + FIELD_DATA_KEY + " TEXT NOT NULL, " - + FIELD_DATA_VALUE + " TEXT NOT NULL, " - + "PRIMARY KEY (" + FIELD_CHUNK + ", " + FIELD_DATA_KEY + ")" - + ");" - ); - } - - private void createBlockInvTable() { - executeSql( - "CREATE TABLE IF NOT EXISTS " - + SqlUtils.mapTable(DataScope.BLOCK_INVENTORY) + "(" - + FIELD_LOCATION + " TEXT NOT NULL, " - + FIELD_INVENTORY_SLOT + " INTEGER NOT NULL, " - + FIELD_INVENTORY_ITEM + " TEXT NOT NULL, " - + "FOREIGN KEY (" + FIELD_LOCATION + ") " - + "REFERENCES " + SqlUtils.mapTable(DataScope.BLOCK_RECORD) + "(" + FIELD_LOCATION + ") " - + "ON UPDATE CASCADE ON DELETE CASCADE, " - + "PRIMARY KEY (" + FIELD_LOCATION + ", " + FIELD_INVENTORY_SLOT + ")" - + ");" - ); - } - - public synchronized void executeSql(String sql) { - super.executeSql(sql); - } - - private synchronized int executeUpdate(String sql) { - try(var conn = ds.getConnection()) { - return SqlUtils.execUpdate(conn, sql); - } catch (SQLException e) { - throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); - } - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite; + +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_ID; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NAME; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_NUM; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_BACKPACK_SIZE; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_CHUNK; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_KEY; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_DATA_VALUE; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_ITEM; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_INVENTORY_SLOT; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_LOCATION; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_NAME; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_PLAYER_UUID; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_RESEARCH_KEY; +import static com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlConstants.FIELD_SLIMEFUN_ID; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlCommonAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.SqlUtils; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; +import java.sql.SQLException; +import java.util.List; + +public class SqliteAdapter extends SqlCommonAdapter { + @Override + public void initStorage(DataType type) { + switch (type) { + case PLAYER_PROFILE -> createProfileTables(); + case BLOCK_STORAGE -> createBlockStorageTables(); + } + } + + @Override + public void setData(RecordKey key, RecordSet item) { + var data = item.getAll(); + var fields = data.keySet(); + var fieldStr = SqlUtils.buildFieldStr(fields); + if (fieldStr.isEmpty()) { + throw new IllegalArgumentException("No data provided in RecordSet."); + } + + var valStr = new StringBuilder(); + var flag = false; + for (var field : fields) { + if (flag) { + valStr.append(", "); + } else { + flag = true; + } + valStr.append(SqlUtils.toSqlValStr(field, data.get(field))); + } + + var updateFields = key.getFields(); + var table = SqlUtils.mapTable(key.getScope()); + + if (!updateFields.isEmpty()) { + if (key.getConditions().isEmpty()) { + throw new IllegalArgumentException("Condition is required for update statement!"); + } + + var row = executeUpdate("UPDATE " + + table + + " SET " + + String.join( + ", ", + updateFields.stream() + .map(field -> { + var val = item.get(field); + if (val == null) { + throw new IllegalArgumentException( + "Cannot find value in RecordSet for the specific key: " + field); + } + return SqlUtils.buildKvStr(field, val); + }) + .toList()) + + SqlUtils.buildConditionStr(key.getConditions()) + + ";"); + if (row > 0) { + return; + } + } + + executeSql("INSERT OR IGNORE INTO " + table + " (" + fieldStr.get() + ") VALUES (" + valStr + ");"); + } + + @Override + public List getData(RecordKey key, boolean distinct) { + return executeQuery((distinct ? "SELECT DISTINCT " : "SELECT ") + + SqlUtils.buildFieldStr(key.getFields()).orElse("*") + + " FROM " + + SqlUtils.mapTable(key.getScope()) + + SqlUtils.buildConditionStr(key.getConditions()) + + ";"); + } + + @Override + public void deleteData(RecordKey key) { + executeSql("DELETE FROM " + + SqlUtils.mapTable(key.getScope()) + + SqlUtils.buildConditionStr(key.getConditions()) + + ";"); + } + + private void createProfileTables() { + createProfileTable(); + createResearchTable(); + createBackpackTable(); + createBackpackInvTable(); + } + + private void createBlockStorageTables() { + createBlockRecordTable(); + createBlockDataTable(); + createBlockInvTable(); + createChunkDataTable(); + } + + private void createProfileTable() { + var table = SqlUtils.mapTable(DataScope.PLAYER_PROFILE); + executeSql("CREATE TABLE IF NOT EXISTS " + + table + + "(" + + FIELD_PLAYER_UUID + + " TEXT PRIMARY KEY NOT NULL, " + + FIELD_PLAYER_NAME + + " TEXT NOT NULL, " + + FIELD_BACKPACK_NUM + + " INTEGER DEFAULT 0" + + ");"); + + executeSql("CREATE INDEX IF NOT EXISTS index_player_name ON " + table + " (" + FIELD_PLAYER_NAME + ");"); + } + + private void createResearchTable() { + var table = SqlUtils.mapTable(DataScope.PLAYER_RESEARCH); + executeSql("CREATE TABLE IF NOT EXISTS " + + table + + "(" + + FIELD_PLAYER_UUID + + " TEXT NOT NULL, " + + FIELD_RESEARCH_KEY + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_PLAYER_UUID + + ") " + + "REFERENCES " + + SqlUtils.mapTable(DataScope.PLAYER_PROFILE) + + "(" + + FIELD_PLAYER_UUID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE);"); + + executeSql("CREATE INDEX IF NOT EXISTS index_player_researches ON " + + table + + " (" + + FIELD_PLAYER_UUID + + ", " + + FIELD_RESEARCH_KEY + + ");"); + } + + private void createBackpackTable() { + var table = SqlUtils.mapTable(DataScope.BACKPACK_PROFILE); + executeSql("CREATE TABLE IF NOT EXISTS " + + table + + "(" + + FIELD_BACKPACK_ID + + " TEXT PRIMARY KEY NOT NULL, " + + FIELD_PLAYER_UUID + + " TEXT NOT NULL, " + + FIELD_BACKPACK_NUM + + " INTEGER NOT NULL, " + + FIELD_BACKPACK_NAME + + " TEXT NULL, " + + FIELD_BACKPACK_SIZE + + " INTEGER NOT NULL, " + + "FOREIGN KEY (" + + FIELD_PLAYER_UUID + + ") " + + "REFERENCES " + + SqlUtils.mapTable(DataScope.PLAYER_PROFILE) + + "(" + + FIELD_PLAYER_UUID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE);"); + + executeSql("CREATE INDEX IF NOT EXISTS index_player_backpack ON " + + table + + " (" + + FIELD_PLAYER_UUID + + ", " + + FIELD_BACKPACK_NUM + + ");"); + } + + private void createBackpackInvTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + SqlUtils.mapTable(DataScope.BACKPACK_INVENTORY) + + "(" + + FIELD_BACKPACK_ID + + " TEXT NOT NULL, " + + FIELD_INVENTORY_SLOT + + " INTEGER NOT NULL, " + + FIELD_INVENTORY_ITEM + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_BACKPACK_ID + + ") " + + "REFERENCES " + + SqlUtils.mapTable(DataScope.BACKPACK_PROFILE) + + "(" + + FIELD_BACKPACK_ID + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_BACKPACK_ID + + ", " + + FIELD_INVENTORY_SLOT + + ")" + + ");"); + } + + private void createBlockRecordTable() { + var table = SqlUtils.mapTable(DataScope.BLOCK_RECORD); + executeSql("CREATE TABLE IF NOT EXISTS " + + table + + "(" + + FIELD_LOCATION + + " TEXT PRIMARY KEY NOT NULL, " + + FIELD_CHUNK + + " TEXT NOT NULL, " + + FIELD_SLIMEFUN_ID + + " TEXT NOT NULL" + + ");"); + + executeSql("CREATE INDEX IF NOT EXISTS index_chunk ON " + table + "(" + FIELD_CHUNK + ");"); + } + + private void createBlockDataTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + SqlUtils.mapTable(DataScope.BLOCK_DATA) + + "(" + + FIELD_LOCATION + + " TEXT NOT NULL, " + + FIELD_DATA_KEY + + " TEXT NOT NULL, " + + FIELD_DATA_VALUE + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_LOCATION + + ") " + + "REFERENCES " + + SqlUtils.mapTable(DataScope.BLOCK_RECORD) + + "(" + + FIELD_LOCATION + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_LOCATION + + ", " + + FIELD_DATA_KEY + + ")" + + ");"); + } + + private void createChunkDataTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + SqlUtils.mapTable(DataScope.CHUNK_DATA) + + "(" + + FIELD_CHUNK + + " TEXT NOT NULL, " + + FIELD_DATA_KEY + + " TEXT NOT NULL, " + + FIELD_DATA_VALUE + + " TEXT NOT NULL, " + + "PRIMARY KEY (" + + FIELD_CHUNK + + ", " + + FIELD_DATA_KEY + + ")" + + ");"); + } + + private void createBlockInvTable() { + executeSql("CREATE TABLE IF NOT EXISTS " + + SqlUtils.mapTable(DataScope.BLOCK_INVENTORY) + + "(" + + FIELD_LOCATION + + " TEXT NOT NULL, " + + FIELD_INVENTORY_SLOT + + " INTEGER NOT NULL, " + + FIELD_INVENTORY_ITEM + + " TEXT NOT NULL, " + + "FOREIGN KEY (" + + FIELD_LOCATION + + ") " + + "REFERENCES " + + SqlUtils.mapTable(DataScope.BLOCK_RECORD) + + "(" + + FIELD_LOCATION + + ") " + + "ON UPDATE CASCADE ON DELETE CASCADE, " + + "PRIMARY KEY (" + + FIELD_LOCATION + + ", " + + FIELD_INVENTORY_SLOT + + ")" + + ");"); + } + + public synchronized void executeSql(String sql) { + super.executeSql(sql); + } + + private synchronized int executeUpdate(String sql) { + try (var conn = ds.getConnection()) { + return SqlUtils.execUpdate(conn, sql); + } catch (SQLException e) { + throw new IllegalStateException("An exception thrown while executing sql: " + sql, e); + } + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java index 7d1c02edc2..a71b05dfe4 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/adapter/sqlite/SqliteConfig.java @@ -1,41 +1,42 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.ISqlCommonConfig; -import com.zaxxer.hikari.HikariConfig; -import com.zaxxer.hikari.HikariDataSource; -import java.util.Properties; -import java.util.concurrent.TimeUnit; - -public record SqliteConfig(String path, int maxConnection) implements ISqlCommonConfig { - public HikariDataSource createDataSource() { - var config = new HikariConfig(); - config.setDriverClassName(driver()); - config.setJdbcUrl(jdbcUrl()); - config.setPoolName("SlimefunHikariPool"); - config.setMaximumPoolSize(maxConnection); - - config.setMaxLifetime(TimeUnit.MINUTES.toMillis(10)); - - var props = new Properties(); - props.setProperty("dataSource.cachePrepStmts", "true"); - props.setProperty("dataSource.prepStmtCacheSize", "250"); - props.setProperty("dataSource.prepStmtCacheSqlLimit", "2048"); - props.setProperty("dataSource.maintainTimeStats", "false"); - - config.setDataSourceProperties(props); - - return new HikariDataSource(config); - } - - public String jdbcUrl() { - return "jdbc:sqlite:" + path + - "?foreign_keys=on" + - "&journal_mode=WAL" + - "&synchronous=NORMAL" + - "&locking_mode=NORMAL"; - } - - public String driver() { - return "org.sqlite.JDBC"; - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlcommon.ISqlCommonConfig; +import com.zaxxer.hikari.HikariConfig; +import com.zaxxer.hikari.HikariDataSource; +import java.util.Properties; +import java.util.concurrent.TimeUnit; + +public record SqliteConfig(String path, int maxConnection) implements ISqlCommonConfig { + public HikariDataSource createDataSource() { + var config = new HikariConfig(); + config.setDriverClassName(driver()); + config.setJdbcUrl(jdbcUrl()); + config.setPoolName("SlimefunHikariPool"); + config.setMaximumPoolSize(maxConnection); + + config.setMaxLifetime(TimeUnit.MINUTES.toMillis(10)); + + var props = new Properties(); + props.setProperty("dataSource.cachePrepStmts", "true"); + props.setProperty("dataSource.prepStmtCacheSize", "250"); + props.setProperty("dataSource.prepStmtCacheSqlLimit", "2048"); + props.setProperty("dataSource.maintainTimeStats", "false"); + + config.setDataSourceProperties(props); + + return new HikariDataSource(config); + } + + public String jdbcUrl() { + return "jdbc:sqlite:" + + path + + "?foreign_keys=on" + + "&journal_mode=WAL" + + "&synchronous=NORMAL" + + "&locking_mode=NORMAL"; + } + + public String driver() { + return "org.sqlite.JDBC"; + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/callback/IAsyncReadCallback.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/callback/IAsyncReadCallback.java index 23b1b1cd0b..4bee6ecc96 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/callback/IAsyncReadCallback.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/callback/IAsyncReadCallback.java @@ -4,6 +4,8 @@ public interface IAsyncReadCallback { default boolean runOnMainThread() { return false; } - default void onResult(T result) { } - default void onResultNotFound() { } + + default void onResult(T result) {} + + default void onResultNotFound() {} } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/DataScope.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/DataScope.java index 6372690455..5795346ec6 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/DataScope.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/DataScope.java @@ -3,13 +3,13 @@ public enum DataScope { NONE, PLAYER_RESEARCH, - PLAYER_PROFILE(new FieldKey[]{FieldKey.PLAYER_UUID}), - BACKPACK_PROFILE(new FieldKey[]{FieldKey.BACKPACK_ID}), - BACKPACK_INVENTORY(new FieldKey[]{FieldKey.BACKPACK_ID, FieldKey.INVENTORY_SLOT}), - BLOCK_RECORD(new FieldKey[]{FieldKey.LOCATION}), - BLOCK_DATA(new FieldKey[]{FieldKey.LOCATION, FieldKey.DATA_KEY}), - CHUNK_DATA(new FieldKey[]{FieldKey.CHUNK, FieldKey.DATA_KEY}), - BLOCK_INVENTORY(new FieldKey[]{FieldKey.LOCATION, FieldKey.INVENTORY_SLOT}); + PLAYER_PROFILE(new FieldKey[] {FieldKey.PLAYER_UUID}), + BACKPACK_PROFILE(new FieldKey[] {FieldKey.BACKPACK_ID}), + BACKPACK_INVENTORY(new FieldKey[] {FieldKey.BACKPACK_ID, FieldKey.INVENTORY_SLOT}), + BLOCK_RECORD(new FieldKey[] {FieldKey.LOCATION}), + BLOCK_DATA(new FieldKey[] {FieldKey.LOCATION, FieldKey.DATA_KEY}), + CHUNK_DATA(new FieldKey[] {FieldKey.CHUNK, FieldKey.DATA_KEY}), + BLOCK_INVENTORY(new FieldKey[] {FieldKey.LOCATION, FieldKey.INVENTORY_SLOT}); private final FieldKey[] primaryKeys; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/FieldMapper.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/FieldMapper.java index d632a2a8f2..d00160b80d 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/FieldMapper.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/FieldMapper.java @@ -21,5 +21,4 @@ public T get(FieldKey key) { public FieldKey get(T key) { return inverseMap.get(key); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordKey.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordKey.java index 480c383666..90d409a68c 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordKey.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordKey.java @@ -1,14 +1,13 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.common; import io.github.bakedlibs.dough.collections.Pair; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.Collections; import java.util.HashSet; import java.util.LinkedList; import java.util.List; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; public class RecordKey extends ScopeKey { private final Set fields; @@ -66,7 +65,10 @@ protected String getKeyStr() { if (changed) { var re = new StringBuilder(); re.append(scope).append("/"); - conditions.forEach(c -> re.append(c.getFirstValue()).append("=").append(c.getSecondValue()).append("/")); + conditions.forEach(c -> re.append(c.getFirstValue()) + .append("=") + .append(c.getSecondValue()) + .append("/")); fields.forEach(f -> re.append(f).append("/")); strKey = re.toString(); changed = false; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordSet.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordSet.java index c4548fded7..3c67ffb70d 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordSet.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/common/RecordSet.java @@ -1,12 +1,11 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.common; import com.xzavier0722.mc.plugin.slimefun4.storage.util.DataUtils; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.ParametersAreNonnullByDefault; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; public class RecordSet { private final Map data; @@ -70,5 +69,4 @@ private void checkReadonly() { throw new IllegalStateException("RecordSet cannot be modified after readonly() called."); } } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java index 2a4258a9b5..a18b5e55e2 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ADataController.java @@ -1,179 +1,186 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.controller; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.ScopeKey; -import com.xzavier0722.mc.plugin.slimefun4.storage.task.DatabaseThreadFactory; -import com.xzavier0722.mc.plugin.slimefun4.storage.task.QueuedWriteTask; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; -import java.util.logging.Logger; -import javax.annotation.OverridingMethodsMustInvokeSuper; - -public abstract class ADataController { - private final DatabaseThreadFactory threadFactory = new DatabaseThreadFactory(); - private final DataType dataType; - private final Map scheduledWriteTasks; - private final ScopedLock lock; - private volatile IDataSourceAdapter dataAdapter; - private ExecutorService readExecutor; - private ExecutorService writeExecutor; - private ExecutorService callbackExecutor; - private volatile boolean destroyed = false; - protected final Logger logger; - - protected ADataController(DataType dataType) { - this.dataType = dataType; - scheduledWriteTasks = new ConcurrentHashMap<>(); - lock = new ScopedLock(); - logger = Logger.getLogger("Slimefun-Data-Controller"); - } - - @OverridingMethodsMustInvokeSuper - public void init(IDataSourceAdapter dataAdapter, int maxReadThread, int maxWriteThread) { - this.dataAdapter = dataAdapter; - dataAdapter.initStorage(dataType); - readExecutor = Executors.newFixedThreadPool(maxReadThread, threadFactory); - writeExecutor = Executors.newFixedThreadPool(maxWriteThread, threadFactory); - callbackExecutor = Executors.newCachedThreadPool(threadFactory); - } - - @OverridingMethodsMustInvokeSuper - public void shutdown() { - if (destroyed) { - return; - } - destroyed = true; - readExecutor.shutdownNow(); - callbackExecutor.shutdownNow(); - try { - float totalTask = scheduledWriteTasks.size(); - var pendingTask = scheduledWriteTasks.size(); - while (pendingTask > 0) { - var doneTaskPercent = String.format("%.1f", (totalTask - pendingTask) / totalTask * 100); - logger.log(Level.INFO, "数据保存中,请稍候... 剩余 {0} 个任务 ({1}%)", new Object[]{pendingTask, doneTaskPercent}); - TimeUnit.SECONDS.sleep(1); - pendingTask = scheduledWriteTasks.size(); - } - - logger.info("数据保存完成."); - } catch (InterruptedException e) { - logger.log(Level.WARNING, "Exception thrown while saving data: ", e); - } - writeExecutor.shutdownNow(); - dataAdapter = null; - } - - protected void scheduleDeleteTask(ScopeKey scopeKey, RecordKey key, boolean forceScopeKey) { - Debug.log(TestCase.DATABASE, "Scheduled remove task for key = {}", key); - - scheduleWriteTask(scopeKey, key, () -> { - dataAdapter.deleteData(key); - Debug.log(TestCase.DATABASE, "Data from key {} deleted.", key); - }, forceScopeKey); - } - - protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, RecordSet data, boolean forceScopeKey) { - Debug.log(TestCase.DATABASE, "Scheduled write task for key = {}, record set = {}", key, data.getAll()); - - scheduleWriteTask(scopeKey, key, () -> { - dataAdapter.setData(key, data); - Debug.log(TestCase.DATABASE, "Data from key {} set, with record set {}", key, data.getAll()); - }, forceScopeKey); - - } - - protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, Runnable task, boolean forceScopeKey) { - lock.lock(scopeKey); - try { - var scopeToUse = forceScopeKey ? scopeKey : key; - var queuedTask = scheduledWriteTasks.get(scopeKey); - if (queuedTask == null && scopeKey != scopeToUse) { - queuedTask = scheduledWriteTasks.get(scopeToUse); - } - - if (queuedTask != null && queuedTask.queue(key, task)) { - return; - } - - queuedTask = new QueuedWriteTask() { - @Override - protected void onSuccess() { - scheduledWriteTasks.remove(scopeToUse); - } - - @Override - protected void onError(Throwable e) { - Slimefun.logger().log(Level.SEVERE, "Exception thrown while executing write task: "); - e.printStackTrace(); - } - }; - queuedTask.queue(key, task); - scheduledWriteTasks.put(scopeToUse, queuedTask); - writeExecutor.submit(queuedTask); - } finally { - lock.unlock(scopeKey); - } - } - - protected void checkDestroy() { - if (destroyed) { - throw new IllegalStateException("Controller cannot be accessed after destroyed."); - } - } - - protected void invokeCallback(IAsyncReadCallback callback, T result) { - if (callback == null) { - return; - } - - Runnable cb; - if (result == null) { - cb = callback::onResultNotFound; - } else { - cb = () -> callback.onResult(result); - } - - if (callback.runOnMainThread()) { - Slimefun.runSync(cb); - } else { - callbackExecutor.submit(cb); - } - } - - protected void scheduleReadTask(Runnable run) { - checkDestroy(); - readExecutor.submit(run); - } - - protected List getData(RecordKey key) { - return getData(key, false); - } - - protected List getData(RecordKey key, boolean distinct) { - return dataAdapter.getData(key, distinct); - } - - protected void setData(RecordKey key, RecordSet data) { - dataAdapter.setData(key, data); - } - - protected void deleteData(RecordKey key) { - dataAdapter.deleteData(key); - } - - public final DataType getDataType() { - return dataType; - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.controller; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.callback.IAsyncReadCallback; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordSet; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.ScopeKey; +import com.xzavier0722.mc.plugin.slimefun4.storage.task.DatabaseThreadFactory; +import com.xzavier0722.mc.plugin.slimefun4.storage.task.QueuedWriteTask; +import io.github.thebusybiscuit.slimefun4.core.debug.Debug; +import io.github.thebusybiscuit.slimefun4.core.debug.TestCase; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.OverridingMethodsMustInvokeSuper; + +public abstract class ADataController { + private final DatabaseThreadFactory threadFactory = new DatabaseThreadFactory(); + private final DataType dataType; + private final Map scheduledWriteTasks; + private final ScopedLock lock; + private volatile IDataSourceAdapter dataAdapter; + private ExecutorService readExecutor; + private ExecutorService writeExecutor; + private ExecutorService callbackExecutor; + private volatile boolean destroyed = false; + protected final Logger logger; + + protected ADataController(DataType dataType) { + this.dataType = dataType; + scheduledWriteTasks = new ConcurrentHashMap<>(); + lock = new ScopedLock(); + logger = Logger.getLogger("Slimefun-Data-Controller"); + } + + @OverridingMethodsMustInvokeSuper + public void init(IDataSourceAdapter dataAdapter, int maxReadThread, int maxWriteThread) { + this.dataAdapter = dataAdapter; + dataAdapter.initStorage(dataType); + readExecutor = Executors.newFixedThreadPool(maxReadThread, threadFactory); + writeExecutor = Executors.newFixedThreadPool(maxWriteThread, threadFactory); + callbackExecutor = Executors.newCachedThreadPool(threadFactory); + } + + @OverridingMethodsMustInvokeSuper + public void shutdown() { + if (destroyed) { + return; + } + destroyed = true; + readExecutor.shutdownNow(); + callbackExecutor.shutdownNow(); + try { + float totalTask = scheduledWriteTasks.size(); + var pendingTask = scheduledWriteTasks.size(); + while (pendingTask > 0) { + var doneTaskPercent = String.format("%.1f", (totalTask - pendingTask) / totalTask * 100); + logger.log(Level.INFO, "数据保存中,请稍候... 剩余 {0} 个任务 ({1}%)", new Object[] {pendingTask, doneTaskPercent}); + TimeUnit.SECONDS.sleep(1); + pendingTask = scheduledWriteTasks.size(); + } + + logger.info("数据保存完成."); + } catch (InterruptedException e) { + logger.log(Level.WARNING, "Exception thrown while saving data: ", e); + } + writeExecutor.shutdownNow(); + dataAdapter = null; + } + + protected void scheduleDeleteTask(ScopeKey scopeKey, RecordKey key, boolean forceScopeKey) { + Debug.log(TestCase.DATABASE, "Scheduled remove task for key = {}", key); + + scheduleWriteTask( + scopeKey, + key, + () -> { + dataAdapter.deleteData(key); + Debug.log(TestCase.DATABASE, "Data from key {} deleted.", key); + }, + forceScopeKey); + } + + protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, RecordSet data, boolean forceScopeKey) { + Debug.log(TestCase.DATABASE, "Scheduled write task for key = {}, record set = {}", key, data.getAll()); + + scheduleWriteTask( + scopeKey, + key, + () -> { + dataAdapter.setData(key, data); + Debug.log(TestCase.DATABASE, "Data from key {} set, with record set {}", key, data.getAll()); + }, + forceScopeKey); + } + + protected void scheduleWriteTask(ScopeKey scopeKey, RecordKey key, Runnable task, boolean forceScopeKey) { + lock.lock(scopeKey); + try { + var scopeToUse = forceScopeKey ? scopeKey : key; + var queuedTask = scheduledWriteTasks.get(scopeKey); + if (queuedTask == null && scopeKey != scopeToUse) { + queuedTask = scheduledWriteTasks.get(scopeToUse); + } + + if (queuedTask != null && queuedTask.queue(key, task)) { + return; + } + + queuedTask = new QueuedWriteTask() { + @Override + protected void onSuccess() { + scheduledWriteTasks.remove(scopeToUse); + } + + @Override + protected void onError(Throwable e) { + Slimefun.logger().log(Level.SEVERE, "Exception thrown while executing write task: "); + e.printStackTrace(); + } + }; + queuedTask.queue(key, task); + scheduledWriteTasks.put(scopeToUse, queuedTask); + writeExecutor.submit(queuedTask); + } finally { + lock.unlock(scopeKey); + } + } + + protected void checkDestroy() { + if (destroyed) { + throw new IllegalStateException("Controller cannot be accessed after destroyed."); + } + } + + protected void invokeCallback(IAsyncReadCallback callback, T result) { + if (callback == null) { + return; + } + + Runnable cb; + if (result == null) { + cb = callback::onResultNotFound; + } else { + cb = () -> callback.onResult(result); + } + + if (callback.runOnMainThread()) { + Slimefun.runSync(cb); + } else { + callbackExecutor.submit(cb); + } + } + + protected void scheduleReadTask(Runnable run) { + checkDestroy(); + readExecutor.submit(run); + } + + protected List getData(RecordKey key) { + return getData(key, false); + } + + protected List getData(RecordKey key, boolean distinct) { + return dataAdapter.getData(key, distinct); + } + + protected void setData(RecordKey key, RecordSet data) { + dataAdapter.setData(key, data); + } + + protected void deleteData(RecordKey key) { + dataAdapter.deleteData(key); + } + + public final DataType getDataType() { + return dataType; + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ASlimefunDataContainer.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ASlimefunDataContainer.java index b0e76ca4ff..e7a6f84a69 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ASlimefunDataContainer.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ASlimefunDataContainer.java @@ -1,12 +1,12 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.controller; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.Collections; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; public abstract class ASlimefunDataContainer { private final String key; @@ -68,8 +68,7 @@ public Set getDataKeys() { return Collections.unmodifiableSet(data.keySet()); } - @Nullable - public String getData(String key) { + @Nullable public String getData(String key) { checkData(); return getCacheInternal(key); } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BackpackCache.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BackpackCache.java index be4ad121bf..59a16e6bd5 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BackpackCache.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BackpackCache.java @@ -1,7 +1,6 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.controller; import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; - import java.util.HashMap; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; @@ -16,7 +15,8 @@ class BackpackCache { } void put(PlayerBackpack backpack) { - numCache.computeIfAbsent(backpack.getOwner().getUniqueId().toString(), k -> new HashMap<>()).put(backpack.getId(), backpack); + numCache.computeIfAbsent(backpack.getOwner().getUniqueId().toString(), k -> new HashMap<>()) + .put(backpack.getId(), backpack); uuidCache.put(backpack.getUniqueId().toString(), backpack); } @@ -45,5 +45,4 @@ void clean() { numCache.clear(); uuidCache.clear(); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java index 2ff514e4cb..ba6fa0be8a 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataConfigWrapper.java @@ -1,15 +1,13 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.controller; - -import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; -import org.apache.commons.lang.NotImplementedException; -import org.bukkit.configuration.file.FileConfiguration; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.io.File; import java.util.HashSet; import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; +import org.apache.commons.lang.NotImplementedException; +import org.bukkit.configuration.file.FileConfiguration; @Deprecated public class BlockDataConfigWrapper extends Config { @@ -21,15 +19,10 @@ public BlockDataConfigWrapper(SlimefunBlockData blockData) { } @Override - public void save() { - - } - + public void save() {} @Override - public void createFile() { - - } + public void createFile() {} @Override public String getString(@Nonnull String path) { @@ -48,7 +41,6 @@ public Set getKeys(@Nonnull String path) { return getKeys(); } - @Override public File getFile() { return null; @@ -59,8 +51,7 @@ public boolean contains(@Nonnull String path) { return getString(path) != null; } - @Nullable - @Override + @Nullable @Override public Object getValue(@Nonnull String path) { return getString(path); } @@ -89,12 +80,8 @@ public void setValue(@Nonnull String path, Object value) { } @Override - public void save(@Nonnull File file) { - - } + public void save(@Nonnull File file) {} @Override - public void reload() { - - } + public void reload() {} } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java index a41e749451..55b09dcf09 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/BlockDataController.java @@ -18,6 +18,17 @@ import io.github.bakedlibs.dough.collections.Pair; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.TimeUnit; +import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import org.bukkit.Bukkit; @@ -28,18 +39,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitTask; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; -import java.util.logging.Level; - public class BlockDataController extends ADataController { private final Map delayedWriteTasks; @@ -75,33 +74,33 @@ private void initLoadData() { } private void loadLoadedWorlds() { - Bukkit.getScheduler().runTaskLater( - Slimefun.instance(), - () -> { - initLoading = true; - for (var world : Bukkit.getWorlds()) { - loadWorld(world); - } - initLoading = false; - }, - 1 - ); + Bukkit.getScheduler() + .runTaskLater( + Slimefun.instance(), + () -> { + initLoading = true; + for (var world : Bukkit.getWorlds()) { + loadWorld(world); + } + initLoading = false; + }, + 1); } private void loadLoadedChunks() { - Bukkit.getScheduler().runTaskLater( - Slimefun.instance(), - () -> { - initLoading = true; - for (var world : Bukkit.getWorlds()) { - for (var chunk : world.getLoadedChunks()) { - loadChunk(chunk, false); - } - } - initLoading = false; - }, - 1 - ); + Bukkit.getScheduler() + .runTaskLater( + Slimefun.instance(), + () -> { + initLoading = true; + for (var world : Bukkit.getWorlds()) { + for (var chunk : world.getLoadedChunks()) { + loadChunk(chunk, false); + } + } + initLoading = false; + }, + 1); } public void initDelayedSaving(Plugin p, int delayedSecond, int forceSavePeriod) { @@ -111,19 +110,23 @@ public void initDelayedSaving(Plugin p, int delayedSecond, int forceSavePeriod) } enableDelayedSaving = true; this.delayedSecond = delayedSecond; - looperTask = Bukkit.getScheduler().runTaskTimerAsynchronously(p, new DelayedSavingLooperTask( - forceSavePeriod, - () -> { - synchronized (delayedWriteTasks) { - return new HashMap<>(delayedWriteTasks); - } - }, - key -> { - synchronized (delayedWriteTasks) { - delayedWriteTasks.remove(key); - } - } - ), 20, 20); + looperTask = Bukkit.getScheduler() + .runTaskTimerAsynchronously( + p, + new DelayedSavingLooperTask( + forceSavePeriod, + () -> { + synchronized (delayedWriteTasks) { + return new HashMap<>(delayedWriteTasks); + } + }, + key -> { + synchronized (delayedWriteTasks) { + delayedWriteTasks.remove(key); + } + }), + 20, + 20); } public boolean isDelayedSavingEnabled() { @@ -155,7 +158,7 @@ void saveNewBlock(Location l, String sfId) { var lKey = LocationUtils.getLocKey(l); var key = new RecordKey(DataScope.BLOCK_RECORD); - //key.addCondition(FieldKey.LOCATION, lKey); + // key.addCondition(FieldKey.LOCATION, lKey); var data = new RecordSet(); data.put(FieldKey.LOCATION, lKey); @@ -208,8 +211,7 @@ void removeBlockDirectly(Location l) { * @param l slimefun block location {@link Location} * @return {@link SlimefunBlockData} */ - @Nullable - @ParametersAreNonnullByDefault + @Nullable @ParametersAreNonnullByDefault public SlimefunBlockData getBlockData(Location l) { checkDestroy(); if (chunkDataLoadMode.readCacheOnly()) { @@ -231,7 +233,8 @@ public SlimefunBlockData getBlockData(Location l) { key.addField(FieldKey.SLIMEFUN_ID); var result = getData(key); - var re = result.isEmpty() ? null : new SlimefunBlockData(l, result.get(0).get(FieldKey.SLIMEFUN_ID)); + var re = + result.isEmpty() ? null : new SlimefunBlockData(l, result.get(0).get(FieldKey.SLIMEFUN_ID)); if (re != null) { chunkData = getChunkDataCache(chunk, true); chunkData.addBlockCacheInternal(re, false); @@ -397,7 +400,8 @@ public void loadWorld(World world) { getData(key, true).forEach(data -> chunkKeys.add(data.get(FieldKey.CHUNK))); chunkKeys.forEach(cKey -> loadChunk(LocationUtils.toChunk(world, cKey), false)); - logger.log(Level.INFO, "世界 {0} 数据加载完成, 耗时 {1}ms", new Object[]{worldName, (System.currentTimeMillis() - start)}); + logger.log( + Level.INFO, "世界 {0} 数据加载完成, 耗时 {1}ms", new Object[] {worldName, (System.currentTimeMillis() - start)}); } private void loadChunkData(SlimefunChunkData chunkData) { @@ -415,11 +419,11 @@ private void loadChunkData(SlimefunChunkData chunkData) { return; } - getData(key).forEach(data -> chunkData.setCacheInternal( - data.get(FieldKey.DATA_KEY), - DataUtils.blockDataDebase64(data.get(FieldKey.DATA_VALUE)), - false) - ); + getData(key) + .forEach(data -> chunkData.setCacheInternal( + data.get(FieldKey.DATA_KEY), + DataUtils.blockDataDebase64(data.get(FieldKey.DATA_VALUE)), + false)); chunkData.setIsDataLoaded(true); } finally { lock.unlock(key); @@ -441,13 +445,11 @@ public void loadBlockData(SlimefunBlockData blockData) { return; } - getData(key).forEach( - recordSet -> blockData.setCacheInternal( + getData(key) + .forEach(recordSet -> blockData.setCacheInternal( recordSet.get(FieldKey.DATA_KEY), DataUtils.blockDataDebase64(recordSet.get(FieldKey.DATA_VALUE)), - false - ) - ); + false)); blockData.setIsDataLoaded(true); var menuPreset = BlockMenuPreset.getPreset(blockData.getSfId()); @@ -458,7 +460,9 @@ public void loadBlockData(SlimefunBlockData blockData) { menuKey.addField(FieldKey.INVENTORY_ITEM); var inv = new ItemStack[54]; - getData(menuKey).forEach(record -> inv[record.getInt(FieldKey.INVENTORY_SLOT)] = record.getItemStack(FieldKey.INVENTORY_ITEM)); + getData(menuKey) + .forEach(record -> inv[record.getInt(FieldKey.INVENTORY_SLOT)] = + record.getItemStack(FieldKey.INVENTORY_ITEM)); blockData.setBlockMenu(new BlockMenu(menuPreset, blockData.getLocation(), inv)); var content = blockData.getMenuContents(); @@ -478,7 +482,8 @@ public void loadBlockDataAsync(SlimefunBlockData blockData, IAsyncReadCallback blockDataList, IAsyncReadCallback> callback) { + public void loadBlockDataAsync( + List blockDataList, IAsyncReadCallback> callback) { scheduleReadTask(() -> blockDataList.forEach(this::loadBlockData)); invokeCallback(callback, blockDataList); } @@ -542,8 +547,8 @@ private void scheduleDelayedBlockInvUpdate(SlimefunBlockData blockData, int slot if (enableDelayedSaving) { scheduleDelayedUpdateTask( new LinkedKey(scopeKey, reqKey), - () -> scheduleBlockInvUpdate(scopeKey, reqKey, blockData.getKey(), blockData.getMenuContents(), slot) - ); + () -> scheduleBlockInvUpdate( + scopeKey, reqKey, blockData.getKey(), blockData.getMenuContents(), slot)); } else { scheduleBlockInvUpdate(scopeKey, reqKey, blockData.getKey(), blockData.getMenuContents(), slot); } @@ -581,8 +586,7 @@ void scheduleDelayedBlockDataUpdate(SlimefunBlockData blockData, String key) { if (enableDelayedSaving) { scheduleDelayedUpdateTask( new LinkedKey(scopeKey, reqKey), - () -> scheduleBlockDataUpdate(scopeKey, reqKey, blockData.getKey(), key, blockData.getData(key)) - ); + () -> scheduleBlockDataUpdate(scopeKey, reqKey, blockData.getKey(), key, blockData.getData(key))); } else { scheduleBlockDataUpdate(scopeKey, reqKey, blockData.getKey(), key, blockData.getData(key)); } @@ -590,7 +594,9 @@ void scheduleDelayedBlockDataUpdate(SlimefunBlockData blockData, String key) { private void removeDelayedBlockDataUpdates(ScopeKey scopeKey) { synchronized (delayedWriteTasks) { - delayedWriteTasks.entrySet().removeIf(each -> scopeKey.equals(each.getKey().getParent())); + delayedWriteTasks + .entrySet() + .removeIf(each -> scopeKey.equals(each.getKey().getParent())); } } @@ -616,8 +622,7 @@ void scheduleDelayedChunkDataUpdate(SlimefunChunkData chunkData, String key) { if (enableDelayedSaving) { scheduleDelayedUpdateTask( new LinkedKey(scopeKey, reqKey), - () -> scheduleChunkDataUpdate(scopeKey, reqKey, chunkData.getKey(), key, chunkData.getData(key)) - ); + () -> scheduleChunkDataUpdate(scopeKey, reqKey, chunkData.getKey(), key, chunkData.getData(key))); } else { scheduleChunkDataUpdate(scopeKey, reqKey, chunkData.getKey(), key, chunkData.getData(key)); } @@ -656,13 +661,14 @@ private void executeAllDelayedTasks() { } private SlimefunChunkData getChunkDataCache(Chunk chunk, boolean createOnNotExists) { - return createOnNotExists ? - loadedChunk.computeIfAbsent(LocationUtils.getChunkKey(chunk), k -> { + return createOnNotExists + ? loadedChunk.computeIfAbsent(LocationUtils.getChunkKey(chunk), k -> { var re = new SlimefunChunkData(chunk); if (!initLoading && chunkDataLoadMode.readCacheOnly()) { re.setIsDataLoaded(true); } return re; - }) : loadedChunk.get(LocationUtils.getChunkKey(chunk)); + }) + : loadedChunk.get(LocationUtils.getChunkKey(chunk)); } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ChunkKey.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ChunkKey.java index 29f2befedf..592aa2bfd2 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ChunkKey.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ChunkKey.java @@ -7,6 +7,7 @@ public class ChunkKey extends ScopeKey { private final Chunk chunk; + public ChunkKey(DataScope scope, Chunk chunk) { super(scope); this.chunk = chunk; @@ -19,11 +20,13 @@ protected String getKeyStr() { @Override public boolean equals(Object obj) { - return obj == this + return obj == this || (obj instanceof ChunkKey other - && scope == other.scope - && chunk.getWorld().getName().equals(other.chunk.getWorld().getName()) - && chunk.getX() == other.chunk.getX() - && chunk.getZ() == other.chunk.getZ()); + && scope == other.scope + && chunk.getWorld() + .getName() + .equals(other.chunk.getWorld().getName()) + && chunk.getX() == other.chunk.getX() + && chunk.getZ() == other.chunk.getZ()); } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ControllerHolder.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ControllerHolder.java index ee55855cb2..763c9aabc1 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ControllerHolder.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ControllerHolder.java @@ -41,5 +41,4 @@ private void put(StorageType type, T controller) { private void remove(StorageType type) { controllers.remove(type); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/LocationKey.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/LocationKey.java index 53f17e0199..02949f640e 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/LocationKey.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/LocationKey.java @@ -20,12 +20,14 @@ protected String getKeyStr() { @Override public boolean equals(Object obj) { - return obj == this + return obj == this || (obj instanceof LocationKey other - && scope == other.scope - && location.getWorld().getName().equals(other.location.getWorld().getName()) - && location.getBlockX() == other.location.getBlockX() - && location.getBlockY() == other.location.getBlockY() - && location.getBlockZ() == other.location.getBlockZ()); + && scope == other.scope + && location.getWorld() + .getName() + .equals(other.location.getWorld().getName()) + && location.getBlockX() == other.location.getBlockX() + && location.getBlockY() == other.location.getBlockY() + && location.getBlockZ() == other.location.getBlockZ()); } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ProfileDataController.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ProfileDataController.java index 44fbdf3076..43d84218eb 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ProfileDataController.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ProfileDataController.java @@ -10,13 +10,6 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import org.bukkit.Bukkit; -import org.bukkit.NamespacedKey; -import org.bukkit.OfflinePlayer; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.Collections; import java.util.HashSet; import java.util.Map; @@ -24,6 +17,12 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.bukkit.Bukkit; +import org.bukkit.NamespacedKey; +import org.bukkit.OfflinePlayer; +import org.bukkit.inventory.ItemStack; public class ProfileDataController extends ADataController { private final BackpackCache backpackCache; @@ -33,11 +32,9 @@ public class ProfileDataController extends ADataController { super(DataType.PLAYER_PROFILE); backpackCache = new BackpackCache(); profileCache = new ConcurrentHashMap<>(); - } - @Nullable - public PlayerProfile getProfile(OfflinePlayer p) { + @Nullable public PlayerProfile getProfile(OfflinePlayer p) { checkDestroy(); var uuid = p.getUniqueId().toString(); var re = profileCache.get(uuid); @@ -68,8 +65,7 @@ public void getProfileAsync(OfflinePlayer p, IAsyncReadCallback c scheduleReadTask(() -> invokeCallback(callback, getProfile(p))); } - @Nullable - public PlayerBackpack getBackpack(OfflinePlayer owner, int num) { + @Nullable public PlayerBackpack getBackpack(OfflinePlayer owner, int num) { checkDestroy(); var uuid = owner.getUniqueId().toString(); var re = backpackCache.get(uuid, num); @@ -99,14 +95,12 @@ public PlayerBackpack getBackpack(OfflinePlayer owner, int num) { DataUtils.profileDataDebase64(result.getOrDef(FieldKey.BACKPACK_NAME, "")), num, size, - getBackpackInv(idStr, size) - ); + getBackpackInv(idStr, size)); backpackCache.put(re); return re; } - @Nullable - public PlayerBackpack getBackpack(String uuid) { + @Nullable public PlayerBackpack getBackpack(String uuid) { var re = backpackCache.get(uuid); if (re != null) { return re; @@ -126,7 +120,7 @@ public PlayerBackpack getBackpack(String uuid) { } var result = resultSet.get(0); - var idStr= result.get(FieldKey.BACKPACK_ID); + var idStr = result.get(FieldKey.BACKPACK_ID); var size = result.getInt(FieldKey.BACKPACK_SIZE); re = new PlayerBackpack( @@ -135,11 +129,9 @@ public PlayerBackpack getBackpack(String uuid) { DataUtils.profileDataDebase64(result.getOrDef(FieldKey.BACKPACK_NAME, "")), result.getInt(FieldKey.BACKPACK_NUMBER), size, - getBackpackInv(idStr, size) - ); + getBackpackInv(idStr, size)); backpackCache.put(re); return re; - } @Nonnull @@ -151,7 +143,8 @@ private ItemStack[] getBackpackInv(String uuid, int size) { var invResult = getData(key); var re = new ItemStack[size]; - invResult.forEach(each -> re[each.getInt(FieldKey.INVENTORY_SLOT)] = each.getItemStack(FieldKey.INVENTORY_ITEM)); + invResult.forEach( + each -> re[each.getInt(FieldKey.INVENTORY_SLOT)] = each.getItemStack(FieldKey.INVENTORY_ITEM)); return re; } @@ -167,9 +160,9 @@ private Set getUnlockedResearchKeys(String uuid) { return Collections.emptySet(); } - return result.stream().map( - record -> NamespacedKey.fromString(record.get(FieldKey.RESEARCH_ID)) - ).collect(Collectors.toSet()); + return result.stream() + .map(record -> NamespacedKey.fromString(record.get(FieldKey.RESEARCH_ID))) + .collect(Collectors.toSet()); } public void getBackpackAsync(OfflinePlayer owner, int num, IAsyncReadCallback callback) { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ScopedLock.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ScopedLock.java index 5633c13394..213eef286a 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ScopedLock.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/ScopedLock.java @@ -1,7 +1,6 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.controller; import com.xzavier0722.mc.plugin.slimefun4.storage.common.ScopeKey; - import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantLock; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunBlockData.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunBlockData.java index aef85ebdef..833a17e69c 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunBlockData.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunBlockData.java @@ -59,13 +59,11 @@ void setBlockMenu(BlockMenu blockMenu) { menu = blockMenu; } - @Nullable - public BlockMenu getBlockMenu() { + @Nullable public BlockMenu getBlockMenu() { return menu; } - @Nullable - public ItemStack[] getMenuContents() { + @Nullable public ItemStack[] getMenuContents() { if (menu == null) { return null; } @@ -92,6 +90,12 @@ public boolean isPendingRemove() { @Override public String toString() { - return "SlimefunBlockData [sfId=" + sfId + ", location=" + location + ", isPendingRemove=" + pendingRemove + "]"; + return "SlimefunBlockData [sfId=" + + sfId + + ", location=" + + location + + ", isPendingRemove=" + + pendingRemove + + "]"; } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunChunkData.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunChunkData.java index 1a6f04859f..c16b23aa11 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunChunkData.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/SlimefunChunkData.java @@ -2,27 +2,23 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.util.LocationUtils; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Location; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - public class SlimefunChunkData extends ASlimefunDataContainer { private static final SlimefunBlockData INVALID_BLOCK_DATA = new SlimefunBlockData( new Location(Bukkit.getWorlds().get(0), Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE), - "INVALID_BLOCK_DATA_SF_KEY" - ); + "INVALID_BLOCK_DATA_SF_KEY"); private final Chunk chunk; private final Map sfBlocks; @@ -59,15 +55,13 @@ public SlimefunBlockData createBlockData(Location l, String sfId) { return re; } - @Nullable - @ParametersAreNonnullByDefault + @Nullable @ParametersAreNonnullByDefault public SlimefunBlockData getBlockData(Location l) { checkData(); return getBlockCacheInternal(LocationUtils.getLocKey(l)); } - @Nullable - @ParametersAreNonnullByDefault + @Nullable @ParametersAreNonnullByDefault public SlimefunBlockData removeBlockData(Location l) { var lKey = LocationUtils.getLocKey(l); var re = removeBlockDataCacheInternal(lKey); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/UUIDKey.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/UUIDKey.java index 5abec6644e..3630e3cb5b 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/UUIDKey.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/controller/UUIDKey.java @@ -2,7 +2,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataScope; import com.xzavier0722.mc.plugin.slimefun4.storage.common.ScopeKey; - import java.util.UUID; class UUIDKey extends ScopeKey { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/event/SlimefunChunkDataLoadEvent.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/event/SlimefunChunkDataLoadEvent.java index 2aadc1f1c2..68d6a54218 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/event/SlimefunChunkDataLoadEvent.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/event/SlimefunChunkDataLoadEvent.java @@ -1,13 +1,12 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.event; import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunChunkData; +import javax.annotation.Nonnull; import org.bukkit.Chunk; import org.bukkit.World; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import javax.annotation.Nonnull; - public class SlimefunChunkDataLoadEvent extends Event { private static final HandlerList handlers = new HandlerList(); private final SlimefunChunkData chunkData; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/listener/ChunkListener.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/listener/ChunkListener.java index b277308210..793167ae91 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/listener/ChunkListener.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/listener/ChunkListener.java @@ -11,5 +11,4 @@ public class ChunkListener implements Listener { public void onChunkLoad(ChunkLoadEvent e) { Slimefun.getDatabaseManager().getBlockDataController().loadChunk(e.getChunk(), e.isNewChunk()); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java index 5788a6e3fa..0627990e31 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/BlockStorageMigrator.java @@ -25,8 +25,7 @@ public class BlockStorageMigrator implements IMigrator { private static final Gson gson = new Gson(); private static volatile boolean migrateLock = false; - private BlockStorageMigrator() { - } + private BlockStorageMigrator() {} public static BlockStorageMigrator getInstance() { return instance; @@ -138,9 +137,9 @@ private void migrateBlock(World world, String sfId, String locStr, String jsonSt var z = Integer.parseInt(arr[3]); var loc = new Location(world, x, y, z); - var blockData = Slimefun.getDatabaseManager().getBlockDataController().createBlock(loc, sfId); - Map data = gson.fromJson(jsonStr, new TypeToken>() { - }.getType()); + var blockData = + Slimefun.getDatabaseManager().getBlockDataController().createBlock(loc, sfId); + Map data = gson.fromJson(jsonStr, new TypeToken>() {}.getType()); for (var each : data.entrySet()) { var key = each.getKey(); if ("id".equals(key)) { @@ -206,9 +205,10 @@ private void migrateChunks() { } var c = w.getChunkAt(Integer.parseInt(arr[2]), Integer.parseInt(arr[3])); - Map data = gson.fromJson(cfg.getString(key), new TypeToken>() { - }.getType()); - var chunkData = Slimefun.getDatabaseManager().getBlockDataController().getChunkData(c); + Map data = + gson.fromJson(cfg.getString(key), new TypeToken>() {}.getType()); + var chunkData = + Slimefun.getDatabaseManager().getBlockDataController().getChunkData(c); data.entrySet().forEach(each -> chunkData.setData(each.getKey(), each.getValue())); } catch (Throwable e) { Slimefun.logger().log(Level.SEVERE, "迁移区块数据时发生错误: " + key, e); diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/MigratorUtil.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/MigratorUtil.java index 18511acac4..ac1e5a242a 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/MigratorUtil.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/MigratorUtil.java @@ -61,6 +61,9 @@ protected static void deleteOldFolder(File dir) { protected static boolean checkMigrateMark() { var backupData = new File("data-storage/Slimefun/old_data/"); - return backupData.exists() && backupData.isDirectory() && backupData.listFiles() != null && backupData.listFiles().length > 0; + return backupData.exists() + && backupData.isDirectory() + && backupData.listFiles() != null + && backupData.listFiles().length > 0; } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/PlayerProfileMigrator.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/PlayerProfileMigrator.java index 3e631025a9..aa7bcd2503 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/PlayerProfileMigrator.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/migrator/PlayerProfileMigrator.java @@ -19,8 +19,7 @@ public class PlayerProfileMigrator implements IMigrator { private static final File playerFolder = new File("data-storage/Slimefun/Players/"); private static volatile boolean migrateLock = false; - private PlayerProfileMigrator() { - } + private PlayerProfileMigrator() {} public static PlayerProfileMigrator getInstance() { return instance; @@ -33,7 +32,8 @@ public String getName() { @Override public boolean hasOldData() { - return !MigratorUtil.checkMigrateMark() && (playerFolder.exists() && playerFolder.listFiles() != null && playerFolder.listFiles().length > 0); + return !MigratorUtil.checkMigrateMark() + && (playerFolder.exists() && playerFolder.listFiles() != null && playerFolder.listFiles().length > 0); } /** @@ -86,7 +86,8 @@ public MigrateStatus migrateData() { } if (MigratorUtil.createDirBackup(playerFolder)) { - Slimefun.logger().log(Level.INFO, "成功迁移 {0} 个玩家数据! 迁移前的数据已储存在 ./data-storage/Slimefun/old_data 下", migratedCount); + Slimefun.logger() + .log(Level.INFO, "成功迁移 {0} 个玩家数据! 迁移前的数据已储存在 ./data-storage/Slimefun/old_data 下", migratedCount); try { Files.deleteIfExists(playerFolder.toPath()); } catch (IOException e) { @@ -149,5 +150,4 @@ private void migratePlayerProfile(@Nonnull OfflinePlayer p) { } profile.setBackpackCount(max); } - } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DatabaseThreadFactory.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DatabaseThreadFactory.java index 72fcb23734..5a7891ab79 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DatabaseThreadFactory.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DatabaseThreadFactory.java @@ -1,14 +1,14 @@ -package com.xzavier0722.mc.plugin.slimefun4.storage.task; - -import java.util.concurrent.ThreadFactory; -import java.util.concurrent.atomic.AtomicInteger; -import javax.annotation.Nonnull; - -public class DatabaseThreadFactory implements ThreadFactory { - private final AtomicInteger threadCount = new AtomicInteger(0); - - @Override - public Thread newThread(@Nonnull Runnable r) { - return new Thread(r, "SF-Database-Thread #" + threadCount.getAndIncrement()); - } -} +package com.xzavier0722.mc.plugin.slimefun4.storage.task; + +import java.util.concurrent.ThreadFactory; +import java.util.concurrent.atomic.AtomicInteger; +import javax.annotation.Nonnull; + +public class DatabaseThreadFactory implements ThreadFactory { + private final AtomicInteger threadCount = new AtomicInteger(0); + + @Override + public Thread newThread(@Nonnull Runnable r) { + return new Thread(r, "SF-Database-Thread #" + threadCount.getAndIncrement()); + } +} diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DelayedSavingLooperTask.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DelayedSavingLooperTask.java index e63cbb9eaf..596dd9fcf0 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DelayedSavingLooperTask.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/DelayedSavingLooperTask.java @@ -1,7 +1,6 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.task; import com.xzavier0722.mc.plugin.slimefun4.storage.common.ScopeKey; - import java.util.Map; import java.util.function.Consumer; import java.util.function.Supplier; @@ -16,10 +15,7 @@ public class DelayedSavingLooperTask implements Runnable { * @param forceSavePeriod: force save period in second */ public DelayedSavingLooperTask( - int forceSavePeriod, - Supplier> taskGetter, - Consumer executeCallback - ) { + int forceSavePeriod, Supplier> taskGetter, Consumer executeCallback) { this.forceSavePeriod = forceSavePeriod; this.executeCallback = executeCallback; this.taskGetter = taskGetter; diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/QueuedWriteTask.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/QueuedWriteTask.java index 03732fda7e..bd87ff9ca7 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/QueuedWriteTask.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/task/QueuedWriteTask.java @@ -1,7 +1,6 @@ package com.xzavier0722.mc.plugin.slimefun4.storage.task; import com.xzavier0722.mc.plugin.slimefun4.storage.common.RecordKey; - import java.util.HashMap; import java.util.LinkedList; import java.util.Map; @@ -11,6 +10,7 @@ public class QueuedWriteTask implements Runnable { private final Queue queue = new LinkedList<>(); private final Map tasks = new HashMap<>(); private volatile boolean done = false; + @Override public final void run() { var task = next(); @@ -29,8 +29,10 @@ public final void run() { e.printStackTrace(); } } - protected void onSuccess() { } - protected void onError(Throwable e) { } + + protected void onSuccess() {} + + protected void onError(Throwable e) {} public synchronized boolean queue(RecordKey key, Runnable next) { if (done) { diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/DataUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/DataUtils.java index 5be08d389e..d895414c89 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/DataUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/DataUtils.java @@ -55,7 +55,9 @@ public static String blockDataBase64(String text) { } public static String blockDataDebase64(String base64Str) { - return Slimefun.getDatabaseManager().isBlockDataBase64Enabled() ? Base64Coder.decodeString(base64Str) : base64Str; + return Slimefun.getDatabaseManager().isBlockDataBase64Enabled() + ? Base64Coder.decodeString(base64Str) + : base64Str; } public static String profileDataBase64(String text) { @@ -63,6 +65,8 @@ public static String profileDataBase64(String text) { } public static String profileDataDebase64(String base64Str) { - return Slimefun.getDatabaseManager().isProfileDataBase64Enabled() ? Base64Coder.decodeString(base64Str) : base64Str; + return Slimefun.getDatabaseManager().isProfileDataBase64Enabled() + ? Base64Coder.decodeString(base64Str) + : base64Str; } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java index 3c6141ae76..72945573db 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/LocationUtils.java @@ -21,16 +21,20 @@ public static Location toLocation(String lKey) { Bukkit.getWorld(strArr[0]), Double.parseDouble(loc[0]), Double.parseDouble(loc[1]), - Double.parseDouble(loc[2]) - ); + Double.parseDouble(loc[2])); } public static boolean isSameChunk(Chunk c1, Chunk c2) { - return c1 == c2 || (isSameWorld(c1.getWorld(), c2.getWorld()) && c1.getX() == c2.getX() && c1.getZ() == c2.getZ()); + return c1 == c2 + || (isSameWorld(c1.getWorld(), c2.getWorld()) && c1.getX() == c2.getX() && c1.getZ() == c2.getZ()); } public static boolean isSameLoc(Location l1, Location l2) { - return l1 == l2 || (isSameChunk(l1.getChunk(), l2.getChunk()) && l1.getBlockX() == l2.getBlockX() && l1.getBlockY() == l2.getBlockY() && l1.getBlockZ() == l2.getBlockZ()); + return l1 == l2 + || (isSameChunk(l1.getChunk(), l2.getChunk()) + && l1.getBlockX() == l2.getBlockX() + && l1.getBlockY() == l2.getBlockY() + && l1.getBlockZ() == l2.getBlockZ()); } public static Chunk toChunk(World w, String cKey) { @@ -47,6 +51,14 @@ public static String locationToString(Location location) { return ""; } - return "[world=" + location.getWorld().getName() + ",x=" + location.getX() + ",y=" + location.getY() + ",z=" + location.getZ() + "]"; + return "[world=" + + location.getWorld().getName() + + ",x=" + + location.getX() + + ",y=" + + location.getY() + + ",z=" + + location.getZ() + + "]"; } } diff --git a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/StorageCacheUtils.java b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/StorageCacheUtils.java index 4043124521..f41d9426ec 100644 --- a/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/StorageCacheUtils.java +++ b/src/main/java/com/xzavier0722/mc/plugin/slimefun4/storage/util/StorageCacheUtils.java @@ -27,8 +27,7 @@ public static boolean hasBlock(Location l) { } @ParametersAreNonnullByDefault - @Nullable - public static SlimefunBlockData getBlock(Location l) { + @Nullable public static SlimefunBlockData getBlock(Location l) { return Slimefun.getDatabaseManager().getBlockDataController().getBlockDataFromCache(l); } @@ -39,15 +38,13 @@ public static boolean isBlock(Location l, String id) { } @ParametersAreNonnullByDefault - @Nullable - public static SlimefunItem getSfItem(Location l) { + @Nullable public static SlimefunItem getSfItem(Location l) { var blockData = getBlock(l); return blockData == null ? null : SlimefunItem.getById(blockData.getSfId()); } @ParametersAreNonnullByDefault - @Nullable - public static String getData(Location loc, String key) { + @Nullable public static String getData(Location loc, String key) { var blockData = getBlock(loc); return blockData == null ? null : blockData.getData(key); } @@ -57,7 +54,11 @@ public static void setData(Location loc, String key, String val) { var block = getBlock(loc); if (block == null) { - Slimefun.logger().log(Level.WARNING, "The specifiy location {0} doesn't have block data!", LocationUtils.locationToString(loc)); + Slimefun.logger() + .log( + Level.WARNING, + "The specifiy location {0} doesn't have block data!", + LocationUtils.locationToString(loc)); } else { block.setData(key, val); } @@ -69,8 +70,7 @@ public static void removeData(Location loc, String key) { } @ParametersAreNonnullByDefault - @Nullable - public static BlockMenu getMenu(Location loc) { + @Nullable public static BlockMenu getMenu(Location loc) { var blockData = getBlock(loc); if (blockData == null) { return null; @@ -100,15 +100,14 @@ public static void requestLoad(SlimefunBlockData blockData) { loadingData.add(blockData); } - Slimefun.getDatabaseManager().getBlockDataController().loadBlockDataAsync( - blockData, - new IAsyncReadCallback<>() { + Slimefun.getDatabaseManager() + .getBlockDataController() + .loadBlockDataAsync(blockData, new IAsyncReadCallback<>() { @Override public void onResult(SlimefunBlockData result) { loadingData.remove(blockData); } - } - ); + }); } public static void executeAfterLoad(SlimefunBlockData data, Runnable execute, boolean runOnMainThread) { @@ -117,19 +116,16 @@ public static void executeAfterLoad(SlimefunBlockData data, Runnable execute, bo return; } - Slimefun.getDatabaseManager().getBlockDataController().loadBlockDataAsync( - data, - new IAsyncReadCallback<>() { - @Override - public boolean runOnMainThread() { - return runOnMainThread; - } + Slimefun.getDatabaseManager().getBlockDataController().loadBlockDataAsync(data, new IAsyncReadCallback<>() { + @Override + public boolean runOnMainThread() { + return runOnMainThread; + } - @Override - public void onResult(SlimefunBlockData result) { - execute.run(); - } - } - ); + @Override + public void onResult(SlimefunBlockData result) { + execute.run(); + } + }); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 889e9af821..f8038f069f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -1,5 +1,9 @@ package io.github.thebusybiscuit.slimefun4.api; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.papermc.lib.PaperLib; import java.io.File; import java.io.PrintStream; import java.nio.charset.StandardCharsets; @@ -13,21 +17,13 @@ import java.util.function.Function; import java.util.logging.Level; import java.util.stream.IntStream; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - +import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.papermc.lib.PaperLib; - -import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; - /** * This class represents an {@link ErrorReport}. * Error reports are thrown when a {@link BlockTicker} is causing problems. @@ -91,7 +87,8 @@ public ErrorReport(T throwable, Location l, SlimefunItem item) { stream.println(" Y: " + l.getBlockY()); stream.println(" Z: " + l.getBlockZ()); stream.println(" Material: " + l.getBlock().getType()); - stream.println(" Block Data: " + l.getBlock().getBlockData().getClass().getName()); + stream.println( + " Block Data: " + l.getBlock().getBlockData().getClass().getName()); stream.println(" State: " + l.getBlock().getState().getClass().getName()); stream.println(); @@ -109,7 +106,8 @@ public ErrorReport(T throwable, Location l, SlimefunItem item) { stream.println("Slimefun Data:"); stream.println(" ID: " + item.getId()); - var blockData = Slimefun.getDatabaseManager().getBlockDataController().getBlockData(l); + var blockData = + Slimefun.getDatabaseManager().getBlockDataController().getBlockData(l); if (blockData == null) { stream.println("Block data is not presented."); } else { @@ -135,7 +133,8 @@ public ErrorReport(T throwable, SlimefunItem item) { this(throwable, item.getAddon(), stream -> { stream.println("SlimefunItem:"); stream.println(" ID: " + item.getId()); - stream.println(" Plugin: " + (item.getAddon() == null ? "Unknown" : item.getAddon().getName())); + stream.println(" Plugin: " + + (item.getAddon() == null ? "Unknown" : item.getAddon().getName())); stream.println(); }); } @@ -217,7 +216,10 @@ private void print(@Nonnull Consumer printer) { addon.getLogger().log(Level.WARNING, ""); addon.getLogger().log(Level.WARNING, "An Error occurred! It has been saved as: "); addon.getLogger().log(Level.WARNING, "/plugins/Slimefun/error-reports/{0}", file.getName()); - addon.getLogger().log(Level.WARNING, "Please put this file on https://pastebin.com/ and report this to the developer(s)."); + addon.getLogger() + .log( + Level.WARNING, + "Please put this file on https://pastebin.com/ and report this to the developer(s)."); if (addon.getBugTrackerURL() != null) { addon.getLogger().log(Level.WARNING, "Bug Tracker: {0}", addon.getBugTrackerURL()); @@ -225,7 +227,12 @@ private void print(@Nonnull Consumer printer) { addon.getLogger().log(Level.WARNING, ""); } catch (Exception x) { - addon.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving an Error-Report for Slimefun " + Slimefun.getVersion()); + addon.getLogger() + .log( + Level.SEVERE, + x, + () -> "An Error occurred while saving an Error-Report for Slimefun " + + Slimefun.getVersion()); } } @@ -234,16 +241,22 @@ private static void scanPlugins(@Nonnull List plugins, @Nonnull List plugins, @Nonnull List i + 1).filter(i -> !new File(path + " (" + i + ").err").exists()); + IntStream stream = + IntStream.iterate(1, i -> i + 1).filter(i -> !new File(path + " (" + i + ").err").exists()); int id = stream.findFirst().getAsInt(); newFile = new File(path + " (" + id + ").err"); @@ -273,12 +287,12 @@ private static void scanPlugins(@Nonnull List plugins, @Nonnull List> function, @Nonnull Runnable runnable) { + public static void tryCatch( + @Nonnull Function> function, @Nonnull Runnable runnable) { try { runnable.run(); } catch (Exception x) { function.apply(x); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java index 511df32ec3..05c2d84347 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/MinecraftVersion.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.api; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.papermc.lib.PaperLib; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.Server; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.papermc.lib.PaperLib; - /** * This enum holds all versions of Minecraft that we currently support. - * + * * @author TheBusyBiscuit * @author Walshy - * + * * @see Slimefun * */ @@ -69,7 +67,7 @@ public enum MinecraftVersion { * This constructs a new {@link MinecraftVersion} with the given name. * This constructor forces the {@link MinecraftVersion} to be real. * It must be a real version of Minecraft. - * + * * @param majorVersion * The major version of minecraft as an {@link Integer} * @param name @@ -85,7 +83,7 @@ public enum MinecraftVersion { * This constructs a new {@link MinecraftVersion} with the given name. * A virtual {@link MinecraftVersion} (unknown or unit test) is not an actual * version of Minecraft but rather a state of the {@link Server} software. - * + * * @param name * The display name of this {@link MinecraftVersion} * @param virtual @@ -99,7 +97,7 @@ public enum MinecraftVersion { /** * This returns the name of this {@link MinecraftVersion} in a readable format. - * + * * @return The name of this {@link MinecraftVersion} */ public @Nonnull String getName() { @@ -112,7 +110,7 @@ public enum MinecraftVersion { * a state of the {@link Server} software used. * Virtual {@link MinecraftVersion MinecraftVersions} include "UNKNOWN" and * "UNIT TEST". - * + * * @return Whether this {@link MinecraftVersion} is virtual or not */ public boolean isVirtual() { @@ -127,10 +125,10 @@ public boolean isVirtual() { * It is equivalent to the "major" version *

* Example: {@literal "1.13"} returns {@literal 13} - * + * * @param minecraftVersion * The {@link Integer} version to match - * + * * @return Whether this {@link MinecraftVersion} matches the specified version id */ public boolean isMinecraftVersion(int minecraftVersion) { @@ -140,12 +138,12 @@ public boolean isMinecraftVersion(int minecraftVersion) { /** * This method checks whether this {@link MinecraftVersion} is newer or equal to * the given {@link MinecraftVersion}, - * + * * An unknown version will default to {@literal false}. - * + * * @param version * The {@link MinecraftVersion} to compare - * + * * @return Whether this {@link MinecraftVersion} is newer or equal to the given {@link MinecraftVersion} */ public boolean isAtLeast(@Nonnull MinecraftVersion version) { @@ -162,7 +160,7 @@ public boolean isAtLeast(@Nonnull MinecraftVersion version) { * this will essentially always return true and result in a tautology. * This is most definitely an oversight from us and should be fixed, therefore * we will trigger an exception. - * + * * In order to not disrupt server operations, this exception is only thrown during * unit tests since the oversight itself will be harmless. */ @@ -175,12 +173,12 @@ public boolean isAtLeast(@Nonnull MinecraftVersion version) { /** * This checks whether this {@link MinecraftVersion} is older than the specified {@link MinecraftVersion}. - * + * * An unknown version will default to {@literal true}. - * + * * @param version * The {@link MinecraftVersion} to compare - * + * * @return Whether this {@link MinecraftVersion} is older than the given one */ public boolean isBefore(@Nonnull MinecraftVersion version) { @@ -192,5 +190,4 @@ public boolean isBefore(@Nonnull MinecraftVersion version) { return version.ordinal() > this.ordinal(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java index fea457064e..376eafaa77 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunAddon.java @@ -1,27 +1,24 @@ package io.github.thebusybiscuit.slimefun4.api; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.logging.Logger; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.java.JavaPlugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This is a very basic interface that will be used to identify * the {@link Plugin} that registered a {@link SlimefunItem}. - * + * * It will also contain some utility methods such as {@link SlimefunAddon#getBugTrackerURL()} * to provide some context when bugs arise. - * + * * It is recommended to implement this interface if you are developing * an Addon. - * + * * @author TheBusyBiscuit * @author ybw0014 * @@ -31,7 +28,7 @@ public interface SlimefunAddon { /** * This method returns the instance of {@link JavaPlugin} that this * {@link SlimefunAddon} refers to. - * + * * @return The instance of your {@link JavaPlugin} */ @Nonnull @@ -39,16 +36,15 @@ public interface SlimefunAddon { /** * This method returns a link to the Bug Tracker of this {@link SlimefunAddon} - * + * * @return The URL for this Plugin's Bug Tracker, or null */ - @Nullable - String getBugTrackerURL(); + @Nullable String getBugTrackerURL(); /** * This method returns the name of this addon, it defaults to the name * of the {@link JavaPlugin} provided by {@link SlimefunAddon#getJavaPlugin()} - * + * * @return The Name of this {@link SlimefunAddon} */ default @Nonnull String getName() { @@ -58,7 +54,7 @@ public interface SlimefunAddon { /** * This method returns the version of this addon, it defaults to the version * of the {@link JavaPlugin} provided by {@link SlimefunAddon#getJavaPlugin()} - * + * * @return The version of this {@link SlimefunAddon} */ default @Nonnull String getPluginVersion() { @@ -68,7 +64,7 @@ public interface SlimefunAddon { /** * This method returns the {@link Logger} of this addon, it defaults to the {@link Logger} * of the {@link JavaPlugin} provided by {@link SlimefunAddon#getJavaPlugin()} - * + * * @return The {@link Logger} of this {@link SlimefunAddon} */ default @Nonnull Logger getLogger() { @@ -80,10 +76,10 @@ public interface SlimefunAddon { * {@link SlimefunAddon}. * It specifically checks whether the given String can be found in {@link PluginDescriptionFile#getDepend()} * or {@link PluginDescriptionFile#getSoftDepend()} - * + * * @param dependency * The dependency to check for - * + * * @return Whether this {@link SlimefunAddon} depends on the given {@link Plugin} */ default boolean hasDependency(@Nonnull String dependency) { @@ -95,7 +91,8 @@ default boolean hasDependency(@Nonnull String dependency) { } PluginDescriptionFile description = getJavaPlugin().getDescription(); - return description.getDepend().contains(dependency) || description.getSoftDepend().contains(dependency); + return description.getDepend().contains(dependency) + || description.getSoftDepend().contains(dependency); } /** @@ -106,5 +103,4 @@ default boolean hasDependency(@Nonnull String dependency) { default @Nullable String getWikiURL() { return null; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java index 04aac77a5f..d6df008508 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/SlimefunBranch.java @@ -1,11 +1,9 @@ package io.github.thebusybiscuit.slimefun4.api; +import io.github.bakedlibs.dough.common.CommonPatterns; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; -import io.github.bakedlibs.dough.common.CommonPatterns; - /** * This enum represents the branch this Slimefun build is on. * development or stable, unofficial or even unknown. @@ -46,14 +44,15 @@ public enum SlimefunBranch { this.official = official; if (!CommonPatterns.ASCII.matcher(name).matches()) { - throw new IllegalStateException("The SlimefunBranch enum contains ILLEGAL CHARACTERS. DO NOT TRANSLATE THIS FILE."); + throw new IllegalStateException( + "The SlimefunBranch enum contains ILLEGAL CHARACTERS. DO NOT TRANSLATE THIS FILE."); } } /** * This returns the name of this {@link SlimefunBranch}. The name is just a more readable * version of the enum constant. - * + * * @return The name of this {@link SlimefunBranch} */ public @Nonnull String getName() { @@ -63,11 +62,10 @@ public enum SlimefunBranch { /** * This method returns whether this {@link SlimefunBranch} is considered official. * Or whether it was unofficially modified. - * + * * @return Whether this branch is an official one. */ public boolean isOfficial() { return official; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java index e7d0851bd8..1354bddf22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AncientAltarCraftEvent.java @@ -3,6 +3,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar; import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -12,9 +14,6 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - /** * This {@link Event} is fired before an item is dropped by an {@link AncientAltar}. * Cancelling this event will make the {@link AncientAltar} drop no item after the recipe is finished. @@ -99,5 +98,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java index 7ca94d4c04..41d6fab59f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidFarmEvent.java @@ -2,15 +2,14 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - /** * This {@link Event} is fired before a {@link FarmerAndroid} harvests a {@link Block}. * If this {@link Event} is cancelled, the {@link Block} will not be harvested. @@ -35,7 +34,8 @@ public class AndroidFarmEvent extends Event implements Cancellable { * @param isAdvanced Whether this is an advanced farming action * @param drop The item to be dropped or null */ - public AndroidFarmEvent(@Nonnull Block block, @Nonnull AndroidInstance android, boolean isAdvanced, @Nullable ItemStack drop) { + public AndroidFarmEvent( + @Nonnull Block block, @Nonnull AndroidInstance android, boolean isAdvanced, @Nullable ItemStack drop) { this.block = block; this.android = android; this.isAdvanced = isAdvanced; @@ -57,8 +57,7 @@ public Block getBlock() { * * @return The harvested item or null */ - @Nullable - public ItemStack getDrop() { + @Nullable public ItemStack getDrop() { return drop; } @@ -111,5 +110,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java index 42f6cc0200..9a74a2a474 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AndroidMineEvent.java @@ -2,14 +2,13 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - /** * This {@link Event} is fired before a {@link MinerAndroid} mines a {@link Block}. * If this {@link Event} is cancelled, the {@link Block} will not be mined. @@ -77,5 +76,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java index f1373e98f9..1cc1eaf6e2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncAutoEnchanterProcessEvent.java @@ -1,17 +1,14 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; import javax.annotation.Nonnull; - +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.apache.commons.lang.Validate; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; - -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; - /** * An {@link Event} that is called whenever an {@link AutoEnchanter} is * enchanting an {@link ItemStack}. @@ -28,7 +25,8 @@ public class AsyncAutoEnchanterProcessEvent extends Event implements Cancellable private boolean cancelled; - public AsyncAutoEnchanterProcessEvent(@Nonnull ItemStack item, @Nonnull ItemStack enchantedBook, @Nonnull BlockMenu menu) { + public AsyncAutoEnchanterProcessEvent( + @Nonnull ItemStack item, @Nonnull ItemStack enchantedBook, @Nonnull BlockMenu menu) { super(true); Validate.notNull(item, "The item to enchant cannot be null!"); @@ -90,4 +88,4 @@ public boolean isCancelled() { public void setCancelled(boolean cancel) { this.cancelled = cancel; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java index f71a7a7ce7..9a3a628e47 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncMachineOperationFinishEvent.java @@ -1,16 +1,14 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.bakedlibs.dough.blocks.BlockPosition; +import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; +import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.bukkit.Bukkit; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; -import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; - /** * This {@link Event} is fired whenever an {@link MachineProcessor} has completed a {@link MachineOperation}. * @@ -26,7 +24,8 @@ public class AsyncMachineOperationFinishEvent extends Event { private final MachineProcessor machineProcessor; private final MachineOperation machineOperation; - public AsyncMachineOperationFinishEvent(BlockPosition pos, MachineProcessor processor, T operation) { + public AsyncMachineOperationFinishEvent( + BlockPosition pos, MachineProcessor processor, T operation) { super(!Bukkit.isPrimaryThread()); this.position = pos; @@ -49,8 +48,7 @@ public BlockPosition getPosition() { * * @return The {@link MachineProcessor} instance of the machine */ - @Nullable - public MachineProcessor getProcessor() { + @Nullable public MachineProcessor getProcessor() { return machineProcessor; } @@ -59,8 +57,7 @@ public MachineProcessor getProcessor() { * * @return The {@link MachineOperation} of the process */ - @Nullable - public MachineOperation getOperation() { + @Nullable public MachineOperation getOperation() { return machineOperation; } @@ -74,4 +71,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java index 8525c4291e..e51be3b205 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AsyncProfileLoadEvent.java @@ -1,16 +1,13 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import java.util.UUID; - import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; - /** * This {@link Event} is called when the {@link PlayerProfile} of a {@link Player} * is loaded into memory. @@ -72,4 +69,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java index d4dfdf8a8e..d77d787cc1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoDisenchantEvent.java @@ -1,13 +1,12 @@ package io.github.thebusybiscuit.slimefun4.api.events; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter; +import javax.annotation.Nonnull; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; - /** * An {@link Event} that is called whenever an {@link AutoDisenchanter} has * disenchanted an {@link ItemStack}. @@ -57,5 +56,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java index f4697a50d5..0ce7b14299 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/AutoEnchantEvent.java @@ -1,14 +1,12 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; import javax.annotation.Nonnull; - import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; - /** * An {@link Event} that is called whenever an {@link AutoEnchanter} is trying to enchant * an {@link ItemStack}. @@ -60,5 +58,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java index 4ea35c510d..0e288b52fb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java @@ -1,8 +1,9 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.event.Cancellable; @@ -11,14 +12,11 @@ import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; - /** * This {@link Event} is fired whenever a {@link BlockPlacer} wants to place a {@link Block}. - * + * * @author TheBusyBiscuit - * + * */ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { @@ -32,7 +30,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { /** * This creates a new {@link BlockPlacerPlaceEvent}. - * + * * @param blockPlacer * The {@link BlockPlacer} * @param placedItem @@ -60,7 +58,7 @@ public Block getBlockPlacer() { /** * This returns the placed {@link ItemStack}. - * + * * @return The placed {@link ItemStack} */ @Nonnull @@ -70,7 +68,7 @@ public ItemStack getItemStack() { /** * This sets the placed {@link ItemStack}. - * + * * @param item * The {@link ItemStack} to be placed */ @@ -80,7 +78,8 @@ public void setItemStack(@Nonnull ItemStack item) { if (!locked) { this.placedItem = item; } else { - SlimefunItem.getByItem(placedItem).warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!"); + SlimefunItem.getByItem(placedItem) + .warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!"); } } @@ -94,7 +93,8 @@ public void setCancelled(boolean cancel) { if (!locked) { cancelled = cancel; } else { - SlimefunItem.getByItem(placedItem).warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!"); + SlimefunItem.getByItem(placedItem) + .warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!"); } } @@ -115,5 +115,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java index b8b93ed4fc..06a8cff8fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ClimbingPickLaunchEvent.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ClimbingPick; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -11,9 +13,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.util.Vector; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - /** * An {@link Event} that is called whenever a {@link Player} has * used a {@link ClimbingPick} on a climbable surface. @@ -33,7 +32,8 @@ public class ClimbingPickLaunchEvent extends PlayerEvent implements Cancellable private boolean cancelled; @ParametersAreNonnullByDefault - public ClimbingPickLaunchEvent(Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) { + public ClimbingPickLaunchEvent( + Player player, Vector velocity, ClimbingPick pick, ItemStack itemStack, Block block) { super(player); this.velocity = velocity; @@ -114,4 +114,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java index a4dd3910a3..ffae0a3a01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/CoolerFeedPlayerEvent.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -11,9 +13,6 @@ import org.bukkit.inventory.meta.PotionMeta; import org.bukkit.potion.PotionEffect; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - /** * This {@link Event} is called whenever a {@link Player} is * fed through a {@link Cooler}. @@ -106,4 +105,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java index c4ecf687c6..0a3676197e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ExplosiveToolBreakBlocksEvent.java @@ -1,10 +1,9 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool; import java.util.List; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -14,8 +13,6 @@ import org.bukkit.event.player.PlayerEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool; - /** * This {@link Event} is called when an {@link ExplosiveTool} is used to break blocks. * @@ -35,7 +32,8 @@ public class ExplosiveToolBreakBlocksEvent extends PlayerEvent implements Cancel private boolean cancelled; @ParametersAreNonnullByDefault - public ExplosiveToolBreakBlocksEvent(Player player, Block block, List blocks, ItemStack item, ExplosiveTool explosiveTool) { + public ExplosiveToolBreakBlocksEvent( + Player player, Block block, List blocks, ItemStack item, ExplosiveTool explosiveTool) { super(player); Validate.notNull(block, "The center block cannot be null!"); @@ -111,4 +109,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java index 1b03fe6343..f0b2c60acb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/GEOResourceGenerationEvent.java @@ -3,6 +3,8 @@ import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager; import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.World; @@ -11,9 +13,6 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - /** * This {@link Event} is fired whenever a {@link GEOResource} is being freshly generated. * This only occurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource} @@ -143,5 +142,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java index 30b3ad1242..1a8f85520e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/MultiBlockInteractEvent.java @@ -1,6 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; @@ -9,9 +11,6 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - /** * This {@link Event} is called when a {@link Player} interacts with a {@link MultiBlock}. * @@ -84,5 +83,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java index ab624060ec..373ce2f4b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerLanguageChangeEvent.java @@ -2,12 +2,11 @@ import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import javax.annotation.Nonnull; import org.bukkit.entity.Player; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import javax.annotation.Nonnull; - /** * This {@link Event} gets called when a {@link Player} has switched their {@link Language}. * @@ -68,5 +67,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java index 1e0a618697..c8e2859cc4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerPreResearchEvent.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.researches.Research; +import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; +import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; - /** * This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}. * This is called before {@link Research#canUnlock(Player)}. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java index f6d613d3d9..92f03399c1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java @@ -3,6 +3,8 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; import io.github.bakedlibs.dough.data.TriStateOptional; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import java.util.Optional; +import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.block.Block; @@ -15,9 +17,6 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import java.util.Optional; - /** * The {@link PlayerRightClickEvent} is our custom version of the {@link PlayerInteractEvent}. * But it is only triggered on right click. @@ -25,7 +24,7 @@ * of the {@link ItemStack} and/or {@link Block} involved. * This allows us (and addons) to efficiently check the used {@link SlimefunItem} without the need * to do a heavy lookup or item comparison. - * + * * @author TheBusyBiscuit * */ @@ -53,7 +52,7 @@ public class PlayerRightClickEvent extends PlayerEvent { /** * This constructs a new {@link PlayerRightClickEvent} based on the original {@link PlayerInteractEvent}. * The {@link Result} of the original {@link PlayerInteractEvent} will be copied. - * + * * @param originalEvent * The original {@link PlayerInteractEvent} */ @@ -68,7 +67,9 @@ public PlayerRightClickEvent(@Nonnull PlayerInteractEvent originalEvent) { itemResult = originalEvent.useItemInHand(); blockResult = originalEvent.useInteractedBlock(); - if (originalEvent.getItem() == null || originalEvent.getItem().getType() == Material.AIR || originalEvent.getItem().getAmount() == 0) { + if (originalEvent.getItem() == null + || originalEvent.getItem().getType() == Material.AIR + || originalEvent.getItem().getAmount() == 0) { itemStack = Optional.empty(); } else { itemStack = Optional.of(originalEvent.getItem()); @@ -78,7 +79,7 @@ public PlayerRightClickEvent(@Nonnull PlayerInteractEvent originalEvent) { /** * This returns the original {@link PlayerInteractEvent} that triggered this * {@link PlayerRightClickEvent}. - * + * * @return The original {@link PlayerInteractEvent} */ @Nonnull @@ -90,7 +91,7 @@ public PlayerInteractEvent getInteractEvent() { * This method returns the {@link ItemStack} that was held in the hand of the {@link Player}. * It will never return null, should there be no {@link ItemStack} then it will return * {@code new ItemStack(Material.AIR)}. - * + * * @return The {@link ItemStack} that the {@link Player} right clicked with */ @Nonnull @@ -101,7 +102,7 @@ public ItemStack getItem() { /** * This returns the hand that was used in this interaction. * Can either be {@code EquipmentSlot.HAND} or {@code EquipmentSlot.OFF_HAND}. - * + * * @return The hand used in this {@link Event} */ @Nonnull @@ -136,7 +137,8 @@ public Optional getSlimefunItem() { public Optional getSlimefunBlock() { if (!slimefunBlock.isComputed()) { if (clickedBlock.isPresent()) { - slimefunBlock.compute(StorageCacheUtils.getSfItem(clickedBlock.get().getLocation())); + slimefunBlock.compute( + StorageCacheUtils.getSfItem(clickedBlock.get().getLocation())); } else { slimefunBlock = TriStateOptional.empty(); } @@ -184,5 +186,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java index 859a80935b..3948766f66 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ReactorExplodeEvent.java @@ -1,18 +1,16 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; - /** * The {@link ReactorExplodeEvent} is called whenever a reactor explodes. - * + * * @author TheBusyBiscuit * */ @@ -33,7 +31,7 @@ public ReactorExplodeEvent(@Nonnull Location l, @Nonnull Reactor reactor) { /** * This returns the {@link Location} where the reactor exploded. - * + * * @return The {@link Location} of this explosion */ @Nonnull @@ -43,7 +41,7 @@ public Location getLocation() { /** * The {@link SlimefunItem} instance of the exploded reactor. - * + * * @return The {@link SlimefunItem} instance */ @Nonnull @@ -61,5 +59,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java index 59d097a2ad..4b73e2dad7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/ResearchUnlockEvent.java @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.researches.Research; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.entity.Player; @@ -9,13 +9,11 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; - /** * This {@link Event} is called whenever a {@link Player} unlocks a {@link Research}. - * + * * @author TheBusyBiscuit - * + * * @see Research * */ @@ -67,5 +65,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java index 8554a69499..f354409671 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockBreakEvent.java @@ -1,21 +1,18 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; import org.bukkit.event.Event; import org.bukkit.event.HandlerList; -import org.bukkit.event.block.BlockEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This {@link Event} is fired whenever a {@link SlimefunItem} placed as a {@link Block} in the world is broken. - * + * * @author J3fftw1 */ public class SlimefunBlockBreakEvent extends Event implements Cancellable { @@ -42,7 +39,7 @@ public class SlimefunBlockBreakEvent extends Event implements Cancellable { @ParametersAreNonnullByDefault public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBroken, SlimefunItem slimefunItem) { super(); - + this.player = player; this.heldItem = heldItem; this.blockBroken = blockBroken; @@ -51,7 +48,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro /** * This gets the broken {@link Block} - * + * * @return The broken {@link Block} */ public @Nonnull Block getBlockBroken() { @@ -60,7 +57,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro /** * This gets the {@link SlimefunItem} being broken - * + * * @return The {@link SlimefunItem} being broken */ public @Nonnull SlimefunItem getSlimefunItem() { @@ -69,7 +66,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro /** * The {@link ItemStack} held by the {@link Player} - * + * * @return The held {@link ItemStack} */ public @Nonnull ItemStack getHeldItem() { @@ -78,7 +75,7 @@ public SlimefunBlockBreakEvent(Player player, ItemStack heldItem, Block blockBro /** * This gets the {@link Player} - * + * * @return The {@link Player} */ public @Nonnull Player getPlayer() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java index 2978b9d77a..7627d20849 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunBlockPlaceEvent.java @@ -1,8 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -10,11 +10,9 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This {@link Event} is fired whenever a {@link SlimefunItem} is placed as a {@link Block} in the world. - * + * * @author J3fftw1 */ public class SlimefunBlockPlaceEvent extends Event implements Cancellable { @@ -68,7 +66,7 @@ public SlimefunBlockPlaceEvent(Player player, ItemStack placedItem, Block blockP /** * This gets the placed {@link ItemStack}. - * + * * @return The placed {@link ItemStack} */ public @Nonnull ItemStack getItemStack() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java index ecf46a5311..0892beb063 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.event.Cancellable; @@ -9,11 +9,9 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; - /** * This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book. - * + * * @author Linox * * @see SlimefunGuideMode @@ -100,5 +98,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java index f023a9c5ce..bd18a8d911 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunItemSpawnEvent.java @@ -1,8 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.events; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.event.Cancellable; @@ -10,8 +10,6 @@ import org.bukkit.event.HandlerList; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; - /** * This {@link Event} is fired whenever slimefun drops an {@link ItemStack}. * Creating a custom {@link Event} for this allows other plugins to provide @@ -108,4 +106,4 @@ public void setCancelled(boolean cancelled) { public @Nonnull HandlerList getHandlers() { return getHandlerList(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java index 46aaadab81..4af2701619 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/WaypointCreateEvent.java @@ -3,6 +3,7 @@ import io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork; import io.github.thebusybiscuit.slimefun4.api.gps.TeleportationManager; import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint; +import javax.annotation.Nonnull; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.entity.Player; @@ -10,8 +11,6 @@ import org.bukkit.event.HandlerList; import org.bukkit.event.player.PlayerEvent; -import javax.annotation.Nonnull; - /** * A {@link WaypointCreateEvent} is called when a {@link Player} creates a new waypoint. * Either manually or through dying with an emergency transmitter. @@ -116,5 +115,4 @@ public static HandlerList getHandlerList() { public HandlerList getHandlers() { return getHandlerList(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java index cb36d7d8c2..d239a33e2b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/package-info.java @@ -2,4 +2,4 @@ * This package contains all extensions of {@link org.bukkit.event.Event} that Slimefun provides * and allows you to listen to. */ -package io.github.thebusybiscuit.slimefun4.api.events; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.events; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java index 8a116e283c..691b5ae55c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/BiomeMapException.java @@ -1,15 +1,13 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; +import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.NamespacedKey; -import io.github.thebusybiscuit.slimefun4.utils.biomes.BiomeMap; - /** * A {@link BiomeMapException} is thrown whenever a {@link BiomeMap} * contains illegal, invalid or unknown values. - * + * * @author TheBusyBiscuit * */ @@ -20,7 +18,7 @@ public class BiomeMapException extends Exception { /** * This constructs a new {@link BiomeMapException} for the given * {@link BiomeMap}'s {@link NamespacedKey} with the provided context. - * + * * @param key * The {@link NamespacedKey} of our {@link BiomeMap} * @param message @@ -34,7 +32,7 @@ public BiomeMapException(NamespacedKey key, String message) { /** * This constructs a new {@link BiomeMapException} for the given * {@link BiomeMap}'s {@link NamespacedKey} with the provided context. - * + * * @param key * The {@link NamespacedKey} of our {@link BiomeMap} * @param cause diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java index bc9b5b4fe0..f66eeec7ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IdConflictException.java @@ -1,13 +1,12 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; -import javax.annotation.ParametersAreNonnullByDefault; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import javax.annotation.ParametersAreNonnullByDefault; /** * An {@link IdConflictException} is thrown whenever two Addons try to add * a {@link SlimefunItem} with the same id. - * + * * @author TheBusyBiscuit * */ @@ -17,7 +16,7 @@ public class IdConflictException extends RuntimeException { /** * Constructs a new {@link IdConflictException} with the given items. - * + * * @param item1 * The first {@link SlimefunItem} with this id * @param item2 @@ -27,5 +26,4 @@ public class IdConflictException extends RuntimeException { public IdConflictException(SlimefunItem item1, SlimefunItem item2) { super("Two items have conflicting ids: " + item1.toString() + " and " + item2.toString()); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java index e80f23a505..7bb894c906 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/IncompatibleItemHandlerException.java @@ -1,23 +1,21 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.plugin.Plugin; - import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.plugin.Plugin; /** * An {@link IncompatibleItemHandlerException} is thrown whenever a {@link Plugin} tried * to add an {@link ItemHandler} to a {@link SlimefunItem} despite the {@link SlimefunItem} * not allowing an {@link ItemHandler} of that type to be added. - * + * * An example for this is the {@link BlockUseHandler}, it can only be added to blocks. * So it will throw this exception when it is added to a non-block item. - * + * * @author TheBusyBiscuit - * + * * @see ItemHandler * @see SlimefunItem * @@ -29,7 +27,7 @@ public class IncompatibleItemHandlerException extends RuntimeException { /** * Constructs a new {@link IncompatibleItemHandlerException} with the given {@link SlimefunItem} and * {@link ItemHandler} - * + * * @param message * The reason why they are incompatible * @param item @@ -39,7 +37,12 @@ public class IncompatibleItemHandlerException extends RuntimeException { */ @ParametersAreNonnullByDefault public IncompatibleItemHandlerException(String message, SlimefunItem item, ItemHandler handler) { - super("The item handler type: \"" + handler.getIdentifier().getSimpleName() + "\" is not compatible with " + item + " (" + message + ')'); + super("The item handler type: \"" + + handler.getIdentifier().getSimpleName() + + "\" is not compatible with " + + item + + " (" + + message + + ')'); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java index c3e94b5229..48c53f4746 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/MissingDependencyException.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; - import javax.annotation.ParametersAreNonnullByDefault; /** @@ -24,7 +23,10 @@ public class MissingDependencyException extends RuntimeException { */ @ParametersAreNonnullByDefault public MissingDependencyException(SlimefunAddon addon, String dependency) { - super("Slimefun Addon \"" + addon.getName() + "\" forgot to define \"" + dependency + "\" as a depend or softdepend inside the plugin.yml file"); + super("Slimefun Addon \"" + + addon.getName() + + "\" forgot to define \"" + + dependency + + "\" as a depend or softdepend inside the plugin.yml file"); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java index 6ee1df5a38..0d1d97143c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/PrematureCodeException.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; - import javax.annotation.ParametersAreNonnullByDefault; /** @@ -24,5 +23,4 @@ public class PrematureCodeException extends RuntimeException { public PrematureCodeException(String message) { super("Slimefun code was invoked before Slimefun finished loading: " + message); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java index ab46ab9ec5..44e2cbaccb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/TagMisconfigurationException.java @@ -1,9 +1,8 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; -import org.bukkit.NamespacedKey; - import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.NamespacedKey; /** * An {@link TagMisconfigurationException} is thrown whenever a {@link SlimefunTag} @@ -38,5 +37,4 @@ public TagMisconfigurationException(NamespacedKey key, String message) { public TagMisconfigurationException(NamespacedKey key, Throwable cause) { super("Tag '" + key + "' has been misconfigured (" + cause.getMessage() + ')', cause); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java index 2d2549bf00..bc78b106c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/UnregisteredItemException.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * An {@link UnregisteredItemException} is thrown whenever a {@link Plugin} tried to * access a method prematurely from {@link SlimefunItem} that can only be called after the * {@link SlimefunItem} was registered. - * + * * In other words... calling this method this early can not result in a logical output, making * this an {@link Exception}. - * + * * @author TheBusyBiscuit * */ @@ -23,7 +21,7 @@ public class UnregisteredItemException extends RuntimeException { /** * Constructs a new {@link UnregisteredItemException} with the given {@link SlimefunItem} - * + * * @param item * The {@link SlimefunItem} that was affected by this */ @@ -31,5 +29,4 @@ public class UnregisteredItemException extends RuntimeException { public UnregisteredItemException(SlimefunItem item) { super(item.toString() + " has not been registered yet."); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java index b3349ab98b..28180bef53 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/WrongItemStackException.java @@ -1,22 +1,20 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * A {@link WrongItemStackException} is thrown when someone tries to alter an {@link ItemStack} * but actually wanted to alter a different one. - * + * * If for example a {@link DamageableItem} accidentally damages the original {@link SlimefunItem} * instead of the held {@link ItemStack}, this will be thrown. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunItemStack * @see SlimefunItem * @@ -34,5 +32,4 @@ public class WrongItemStackException extends RuntimeException { public WrongItemStackException(String message) { super("You probably wanted to alter a different ItemStack: " + message); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java index da014fff27..d0548e35f1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/exceptions/package-info.java @@ -2,4 +2,4 @@ * This package contains all different extensions of {@link java.lang.Exception} that Slimefun * uses internally. */ -package io.github.thebusybiscuit.slimefun4.api.exceptions; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.exceptions; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java index 36aa5aee76..533108ee6c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/GEOResource.java @@ -1,7 +1,11 @@ package io.github.thebusybiscuit.slimefun4.api.geo; +import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent; +import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; +import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; import javax.annotation.Nonnull; - import org.bukkit.Chunk; import org.bukkit.Keyed; import org.bukkit.World; @@ -10,23 +14,17 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; -import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner; - /** * A {@link GEOResource} is a virtual resource that can be thought of as world-gen. * However it cannot be found in a {@link World}. - * + * * This resource only exists in memory and can be retrieved through a {@link GEOMiner} * or similar devices. - * + * * A {@link GEOResource} can be detected via the {@link GEOScanner}. - * + * * @author TheBusyBiscuit - * + * * @see ResourceManager * @see GEOMiner * @see GEOScanner @@ -37,26 +35,26 @@ public interface GEOResource extends Keyed { /** * Returns the default supply of this resource in that biome - * + * * @param environment * The {@link Environment} this area is currently in (NORMAL / NETHER / THE_END) * @param biome * The {@link Biome} this area is currently in. - * + * * @return The default supply found in a {@link Chunk} with the given {@link Biome} */ int getDefaultSupply(@Nonnull Environment environment, @Nonnull Biome biome); /** * Returns how much the value may deviate from the default supply (positive only). - * + * * @return The deviation or spread of the supply */ int getMaxDeviation(); /** * Returns the name of this resource (e.g. "Oil") - * + * * @return The name of this Resource */ @Nonnull @@ -65,7 +63,7 @@ public interface GEOResource extends Keyed { /** * This {@link ItemStack} is used for display-purposes in the GEO Scanner. * But will also determine the Output of the GEO Miner, if it is applicable for that. - * + * * @return The {@link ItemStack} version of this Resource. */ @Nonnull @@ -74,7 +72,7 @@ public interface GEOResource extends Keyed { /** * Returns whether this Resource can be obtained using a GEO Miner. * This will automatically add it to the GEO - Miner. - * + * * @return Whether you can get obtain this resource using a GEO Miner. */ boolean isObtainableFromGEOMiner(); @@ -89,15 +87,15 @@ default void register() { /** * This method returns a localized name for this {@link GEOResource} in the * {@link Language} the given {@link Player} selected. - * + * * @param p * The {@link Player} to localize the name for. * @return The localized name for this {@link GEOResource} */ @Nonnull default String getName(@Nonnull Player p) { - String name = Slimefun.getLocalization().getResourceString(p, "resources." + getKey().getNamespace() + "." + getKey().getKey()); + String name = Slimefun.getLocalization() + .getResourceString(p, "resources." + getKey().getNamespace() + "." + getKey().getKey()); return name == null ? getName() : name; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java index dab7151f39..8d8701a429 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java @@ -13,6 +13,13 @@ import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Locale; +import java.util.OptionalInt; +import java.util.concurrent.ThreadLocalRandom; +import javax.annotation.Nonnull; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -25,20 +32,12 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; -import java.util.Locale; -import java.util.OptionalInt; -import java.util.concurrent.ThreadLocalRandom; - /** * The {@link ResourceManager} is responsible for registering and managing a {@link GEOResource}. * You have to use the {@link ResourceManager} if you want to generate or consume a {@link GEOResource} too. - * + * * @author TheBusyBiscuit - * + * * @see GEOResource * @see GEOMiner * @see GEOScanner @@ -46,12 +45,14 @@ */ public class ResourceManager { - private final int[] backgroundSlots = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 48, 49, 50, 52, 53 }; + private final int[] backgroundSlots = { + 0, 1, 2, 3, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 48, 49, 50, 52, 53 + }; private final Config config; /** * This will create a new {@link ResourceManager}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -62,7 +63,7 @@ public ResourceManager(@Nonnull Slimefun plugin) { /** * This method registers the given {@link GEOResource}. * It may never be called directly, use {@link GEOResource#register()} instead. - * + * * @param resource * The {@link GEOResource} to register */ @@ -72,7 +73,8 @@ void register(@Nonnull GEOResource resource) { // Resources may only be registered once if (Slimefun.getRegistry().getGEOResources().containsKey(resource.getKey())) { - throw new IllegalArgumentException("GEO-Resource \"" + resource.getKey() + "\" has already been registered!"); + throw new IllegalArgumentException( + "GEO-Resource \"" + resource.getKey() + "\" has already been registered!"); } String key = resource.getKey().getNamespace() + '.' + resource.getKey().getKey(); @@ -91,7 +93,7 @@ void register(@Nonnull GEOResource resource) { * This method returns the amount of a certain {@link GEOResource} found in a given {@link Chunk}. * The result is an {@link OptionalInt} which will be empty if this {@link GEOResource} * has not been generated at that {@link Location} yet. - * + * * @param resource * The {@link GEOResource} to query * @param world @@ -100,7 +102,7 @@ void register(@Nonnull GEOResource resource) { * The {@link Chunk} x coordinate * @param z * The {@link Chunk} z coordinate - * + * * @return An {@link OptionalInt}, either empty or containing the amount of the given {@link GEOResource} */ public @Nonnull OptionalInt getSupplies(@Nonnull GEOResource resource, @Nonnull World world, int x, int z) { @@ -147,7 +149,7 @@ public void onResultNotFound() { /** * This method will set the supplies in a given {@link Chunk} to the specified value. - * + * * @param resource * The {@link GEOResource} * @param world @@ -164,12 +166,14 @@ public void setSupplies(@Nonnull GEOResource resource, @Nonnull World world, int Validate.notNull(world, "World cannot be null"); String key = resource.getKey().toString().replace(':', '-'); - Slimefun.getDatabaseManager().getBlockDataController().getChunkDataAsync(world.getChunkAt(x, z), new IAsyncReadCallback<>() { - @Override - public void onResult(SlimefunChunkData result) { - result.setData(key, String.valueOf(value)); - } - }); + Slimefun.getDatabaseManager() + .getBlockDataController() + .getChunkDataAsync(world.getChunkAt(x, z), new IAsyncReadCallback<>() { + @Override + public void onResult(SlimefunChunkData result) { + result.setData(key, String.valueOf(value)); + } + }); } /** @@ -178,7 +182,7 @@ public void onResult(SlimefunChunkData result) { *

* This method will invoke {@link #setSupplies(GEOResource, World, int, int, int)} and also calls a * {@link GEOResourceGenerationEvent}. - * + * * @param resource * The {@link GEOResource} to generate * @param world @@ -187,7 +191,7 @@ public void onResult(SlimefunChunkData result) { * The x coordinate of that {@link Chunk} * @param z * The z coordinate of that {@link Chunk} - * + * * @return The new supply value */ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int y, int z) { @@ -212,7 +216,9 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, int max = resource.getMaxDeviation(); if (max <= 0) { - throw new IllegalStateException("GEO Resource \"" + resource.getKey() + "\" was misconfigured! getMaxDeviation() must return a value higher than zero!"); + throw new IllegalStateException("GEO Resource \"" + + resource.getKey() + + "\" was misconfigured! getMaxDeviation() must return a value higher than zero!"); } value += ThreadLocalRandom.current().nextInt(max); @@ -230,11 +236,11 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, /** * This method will start a geo-scan at the given {@link Block} and display the result * of that scan to the given {@link Player}. - * + * * Note that scans are always per {@link Chunk}, not per {@link Block}, the {@link Block} * parameter only determines the {@link Location} that was clicked but it will still scan * the entire {@link Chunk}. - * + * * @param p * The {@link Player} who requested these results * @param block @@ -244,7 +250,8 @@ private int generate(@Nonnull GEOResource resource, @Nonnull World world, int x, */ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { if (Slimefun.getGPSNetwork().getNetworkComplexity(p.getUniqueId()) < 600) { - Slimefun.getLocalization().sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600")); + Slimefun.getLocalization() + .sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600")); return; } @@ -258,8 +265,20 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(4, new CustomItemStack(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler()); - List resources = new ArrayList<>(Slimefun.getRegistry().getGEOResources().values()); + menu.addItem( + 4, + new CustomItemStack( + HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), + ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), + "", + "&8\u21E8 &7" + + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + + ": " + + block.getWorld().getName(), + "&8\u21E8 &7X: " + x + " Z: " + z), + ChestMenuUtils.getEmptyClickHandler()); + List resources = + new ArrayList<>(Slimefun.getRegistry().getGEOResources().values()); resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT))); int index = 10; @@ -269,9 +288,11 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { GEOResource resource = resources.get(i); OptionalInt optional = getSupplies(resource, block.getWorld(), x, z); int supplies = optional.orElseGet(() -> generate(resource, block.getWorld(), x, block.getY(), z)); - String suffix = Slimefun.getLocalization().getResourceString(p, ChatUtils.checkPlurality("tooltips.unit", supplies)); + String suffix = Slimefun.getLocalization() + .getResourceString(p, ChatUtils.checkPlurality("tooltips.unit", supplies)); - ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix); + ItemStack item = new CustomItemStack( + resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix); if (supplies > 1) { item.setAmount(Math.min(supplies, item.getMaxStackSize())); @@ -305,5 +326,4 @@ public void scan(@Nonnull Player p, @Nonnull Block block, int page) { menu.open(p); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java index 15243da62f..e63979f86b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/package-info.java @@ -2,4 +2,4 @@ * This package contains classes that are centered around the * {@link io.github.thebusybiscuit.slimefun4.api.geo.GEOResource} API. */ -package io.github.thebusybiscuit.slimefun4.api.geo; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.geo; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index d3af361856..eeeaf77748 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -17,6 +17,14 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Locale; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; @@ -28,30 +36,24 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Locale; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - /** * The {@link GPSNetwork} is a manager class for all {@link GPSTransmitter Transmitters} and waypoints. * There can only be one instance of this class per {@link Server}. * It is also responsible for teleportation and resource management. - * + * * @author TheBusyBiscuit - * + * * @see TeleportationManager * @see ResourceManager * */ public class GPSNetwork { - private final int[] border = { 0, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 }; - private final int[] inventory = { 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 }; + private final int[] border = { + 0, 1, 3, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 + }; + private final int[] inventory = {19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 + }; private final Map> transmitters = new HashMap<>(); private final TeleportationManager teleportation = new TeleportationManager(); @@ -61,7 +63,7 @@ public class GPSNetwork { /** * This constructs a new {@link GPSNetwork}. * Note that this network is per {@link Server} and not per {@link Player}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -71,7 +73,7 @@ public GPSNetwork(@Nonnull Slimefun plugin) { /** * This method updates the status of a {@link GPSTransmitter}. - * + * * @param l * The {@link Location} of the {@link GPSTransmitter} * @param uuid @@ -93,10 +95,10 @@ public void updateTransmitter(@Nonnull Location l, @Nonnull UUID uuid, boolean o * This method calculates the GPS complexity for the given {@link UUID}. * The complexity is determined by the Y level of each {@link GPSTransmitter} * multiplied by the multiplier of that transmitter. - * + * * @param uuid * The {@link UUID} who to calculate it for - * + * * @return The network complexity for that {@link UUID} */ public int getNetworkComplexity(@Nonnull UUID uuid) { @@ -121,10 +123,10 @@ public int getNetworkComplexity(@Nonnull UUID uuid) { /** * This method returns the amount of {@link GPSTransmitter Transmitters} for the * given {@link UUID}. - * + * * @param uuid * The {@link UUID} who these transmitters belong to - * + * * @return The amount of transmitters */ public int countTransmitters(@Nonnull UUID uuid) { @@ -135,29 +137,46 @@ public int countTransmitters(@Nonnull UUID uuid) { /** * This method opens the {@link GPSTransmitter} control panel to the given * {@link Player}. - * + * * @param p * The {@link Player} */ public void openTransmitterControlPanel(@Nonnull Player p) { - ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title")); + ChestMenu menu = new ChestMenu( + ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title")); for (int slot : border) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, im -> { - im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters")); + im.setDisplayName(ChatColor.GRAY + + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters")); im.setLore(null); })); menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler()); int complexity = getNetworkComplexity(p.getUniqueId()); - menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7网络信息", "", "&8\u21E8 &7状态: " + getStatusText(p, complexity), "&8\u21E8 &7复杂度: &f" + complexity)); + menu.addItem( + 4, + new CustomItemStack( + SlimefunItems.GPS_CONTROL_PANEL, + "&7网络信息", + "", + "&8\u21E8 &7状态: " + getStatusText(p, complexity), + "&8\u21E8 &7复杂度: &f" + complexity)); menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler()); - menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem( + 6, + new CustomItemStack( + HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), + "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), + "", + ChatColor.GRAY + + "\u21E8 " + + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(6, (pl, slot, item, action) -> { openWaypointControlPanel(pl); return false; @@ -174,7 +193,18 @@ public void openTransmitterControlPanel(@Nonnull Player p) { if (sfi instanceof GPSTransmitter transmitter) { int slot = inventory[index]; - menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&bGPS 发射器", "&8\u21E8 &7世界: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7信号强度: &f" + transmitter.getMultiplier(l.getBlockY()), "&8\u21E8 &7延迟: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms")); + menu.addItem( + slot, + new CustomItemStack( + SlimefunItems.GPS_TRANSMITTER, + "&bGPS 发射器", + "&8\u21E8 &7世界: &f" + l.getWorld().getName(), + "&8\u21E8 &7X: &f" + l.getX(), + "&8\u21E8 &7Y: &f" + l.getY(), + "&8\u21E8 &7Z: &f" + l.getZ(), + "", + "&8\u21E8 &7信号强度: &f" + transmitter.getMultiplier(l.getBlockY()), + "&8\u21E8 &7延迟: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms")); menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler()); index++; @@ -189,14 +219,14 @@ public void openTransmitterControlPanel(@Nonnull Player p) { * The icon is dependent on the {@link Environment} of the waypoint's {@link World}. * However if the name of this waypoint indicates that this is actually a deathmarker * then a different texture will be used. - * + * * Otherwise it will return a globe, a nether or end sphere according to the {@link Environment}. - * + * * @param name * The name of a waypoint * @param environment * The {@link Environment} of the waypoint's {@link World} - * + * * @return An icon for this waypoint */ @ParametersAreNonnullByDefault @@ -223,23 +253,43 @@ public void openTransmitterControlPanel(@Nonnull Player p) { public void openWaypointControlPanel(@Nonnull Player p) { PlayerProfile.get(p, profile -> { - ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title")); + ChestMenu menu = new ChestMenu( + ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title")); for (int slot : border) { menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem( + 2, + new CustomItemStack( + SlimefunItems.GPS_TRANSMITTER, + "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), + "", + ChatColor.GRAY + + "\u21E8 " + + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(2, (pl, slot, item, action) -> { openTransmitterControlPanel(pl); return false; }); int complexity = getNetworkComplexity(p.getUniqueId()); - menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7网络信息", "", "&8\u21E8 &7状态: " + (complexity > 0 ? "&2&l在线" : "&4&l离线"), "&8\u21E8 &7复杂度: &f" + complexity)); + menu.addItem( + 4, + new CustomItemStack( + SlimefunItems.GPS_CONTROL_PANEL, + "&7网络信息", + "", + "&8\u21E8 &7状态: " + (complexity > 0 ? "&2&l在线" : "&4&l离线"), + "&8\u21E8 &7复杂度: &f" + complexity)); menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler()); - menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"))); + menu.addItem( + 6, + new CustomItemStack( + HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), + "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"))); menu.addMenuClickHandler(6, ChestMenuUtils.getEmptyClickHandler()); int index = 0; @@ -251,7 +301,17 @@ public void openWaypointControlPanel(@Nonnull Player p) { int slot = inventory[index]; Location l = waypoint.getLocation(); - menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7世界: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete")); + menu.addItem( + slot, + new CustomItemStack( + waypoint.getIcon(), + waypoint.getName().replace("player:death ", ""), + "&8\u21E8 &7世界: &f" + l.getWorld().getName(), + "&8\u21E8 &7X: &f" + l.getX(), + "&8\u21E8 &7Y: &f" + l.getY(), + "&8\u21E8 &7Z: &f" + l.getZ(), + "", + "&8\u21E8 &cClick to delete")); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { profile.removeWaypoint(waypoint); SoundEffect.GPS_NETWORK_OPEN_PANEL_SOUND.playFor(p); @@ -270,7 +330,7 @@ public void openWaypointControlPanel(@Nonnull Player p) { /** * This method will prompt the given {@link Player} to enter a name for a waypoint. * After entering the name, it will be added to his waypoint list. - * + * * @param p * The {@link Player} who should get a new waypoint * @param l @@ -295,7 +355,7 @@ public void createWaypoint(@Nonnull Player p, @Nonnull Location l) { /** * This method adds a new waypoint with the given name and {@link Location} for that {@link Player}. - * + * * @param p * The {@link Player} to get the new waypoint * @param name @@ -319,11 +379,18 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { - String id = ChatColor.stripColor(ChatColors.color(event.getName())).toUpperCase(Locale.ROOT).replace(' ', '_'); + String id = ChatColor.stripColor(ChatColors.color(event.getName())) + .toUpperCase(Locale.ROOT) + .replace(' ', '_'); for (Waypoint wp : profile.getWaypoints()) { if (wp.getId().equals(id)) { - Slimefun.getLocalization().sendMessage(p, "gps.waypoint.duplicate", true, msg -> msg.replace("%waypoint%", event.getName())); + Slimefun.getLocalization() + .sendMessage( + p, + "gps.waypoint.duplicate", + true, + msg -> msg.replace("%waypoint%", event.getName())); return; } } @@ -340,10 +407,10 @@ public void addWaypoint(@Nonnull Player p, @Nonnull String name, @Nonnull Locati /** * This method returns a {@link Set} of {@link Location Locations} for all {@link GPSTransmitter Transmitters} * owned by the given {@link UUID}. - * + * * @param uuid * The {@link UUID} owning those transmitters - * + * * @return A {@link Set} with all {@link Location Locations} of transmitters for this {@link UUID} */ @Nonnull @@ -354,7 +421,7 @@ public Set getTransmitters(@Nonnull UUID uuid) { /** * This returns the {@link TeleportationManager} for this {@link GPSNetwork}. * It is responsible for all actions that relate to the {@link Teleporter}. - * + * * @return The {@link TeleportationManager} for this {@link GPSNetwork} */ @Nonnull @@ -365,12 +432,11 @@ public TeleportationManager getTeleportationManager() { /** * This returns the {@link ResourceManager} for this {@link GPSNetwork}. * Use this to access {@link GEOResource GEOResources}. - * + * * @return The {@link ResourceManager} for this {@link GPSNetwork} */ @Nonnull public ResourceManager getResourceManager() { return resourceManager; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index 449cc46855..afb6dc8977 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -1,13 +1,22 @@ package io.github.thebusybiscuit.slimefun4.api.gps; +import io.github.bakedlibs.dough.common.ChatColors; +import io.github.bakedlibs.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; +import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.papermc.lib.PaperLib; import java.util.HashSet; import java.util.Set; import java.util.UUID; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - +import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -18,33 +27,25 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.bakedlibs.dough.common.ChatColors; -import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.papermc.lib.PaperLib; - -import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; - /** * The {@link TeleportationManager} handles the process of teleportation for a {@link Player} * who is using a {@link Teleporter}. - * + * * @author TheBusyBiscuit - * + * * @see GPSNetwork * @see Teleporter * */ public final class TeleportationManager { - private final int[] teleporterBorder = { 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 }; - private final int[] teleporterInventory = { 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 }; + private final int[] teleporterBorder = { + 0, 1, 2, 3, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, + 52, 53 + }; + private final int[] teleporterInventory = { + 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34, 37, 38, 39, 40, 41, 42, 43 + }; /** * This {@link Set} holds the {@link UUID} of all Players that are @@ -79,7 +80,12 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity) menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(4, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title"))); + menu.addItem( + 4, + new CustomItemStack( + HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), + ChatColor.YELLOW + + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title"))); menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler()); Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D); @@ -97,17 +103,27 @@ public void openTeleporterGUI(Player p, UUID ownerUUID, Block b, int complexity) // @formatter:off String[] lore = { "", - "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(), + "&8\u21E8 &7" + + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + + ": &f" + + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), - "&8\u21E8 &7" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s", + "&8\u21E8 &7" + + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + + ": &f" + + time + + "s", "", "&8\u21E8 &c" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip") }; // @formatter:on - menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore)); + menu.addItem( + slot, + new CustomItemStack( + waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore)); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { pl.closeInventory(); teleport(pl.getUniqueId(), complexity, source, l, false); @@ -136,21 +152,21 @@ public void teleport(UUID uuid, int complexity, Location source, Location destin * to the destination {@link Location}, given the specified complexity. *

* The returned time will be measured in 500ms intervals. - * + * *

    *
  • A returned time of {@literal 100} will mean 50,000ms (50s) of real-life time.
  • *
  • A returned time of {@literal 10} will mean 5,000ms (5s) of real-life time.
  • *
  • A returned time of {@literal 2} will mean 1,000ms (1s) of real-life time.
  • *
  • and so on...
  • *
- * + * * @param complexity * The complexity of the {@link GPSNetwork} * @param source * The source {@link Location} * @param destination * The destination {@link Location} - * + * * @return The amount of time the teleportation will take */ public int getTeleportationTime(int complexity, @Nonnull Location source, @Nonnull Location destination) { @@ -179,31 +195,52 @@ private int distanceSquared(Location source, Location destination) { } private boolean isValid(@Nullable Player p, @Nonnull Location source) { - return p != null && p.isValid() && p.getWorld().getUID().equals(source.getWorld().getUID()) && p.getLocation().distanceSquared(source) < 2.0; + return p != null + && p.isValid() + && p.getWorld().getUID().equals(source.getWorld().getUID()) + && p.getLocation().distanceSquared(source) < 2.0; } private void cancel(@Nonnull UUID uuid, @Nullable Player p) { teleporterUsers.remove(uuid); if (p != null) { - p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), ChatColors.color("&c&k40&f&c%"), 20, 60, 20); + p.sendTitle( + ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), + ChatColors.color("&c&k40&f&c%"), + 20, + 60, + 20); } } @ParametersAreNonnullByDefault - private void updateProgress(UUID uuid, int speed, int progress, Location source, Location destination, boolean resistance) { + private void updateProgress( + UUID uuid, int speed, int progress, Location source, Location destination, boolean resistance) { Player p = Bukkit.getPlayer(uuid); if (isValid(p, source)) { if (progress > 99) { - p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20); - PaperLib.teleportAsync(p, destination).thenAccept(success -> onTeleport(p, destination, success, resistance)); + p.sendTitle( + ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), + ChatColors.color("&b100%"), + 20, + 60, + 20); + PaperLib.teleportAsync(p, destination) + .thenAccept(success -> onTeleport(p, destination, success, resistance)); } else { - p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0); + p.sendTitle( + ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), + ChatColors.color("&b" + progress + "%"), + 0, + 60, + 0); source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F); SoundEffect.TELEPORT_UPDATE_SOUND.playFor(p); - Slimefun.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); + Slimefun.runSync( + () -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); } } else { cancel(uuid, p); @@ -225,7 +262,8 @@ private void onTeleport(Player p, Location destination, boolean success, boolean } // Spawn some particles for aesthetic reasons. - Location loc = new Location(destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()); + Location loc = new Location( + destination.getWorld(), destination.getX(), destination.getY() + 1, destination.getZ()); destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F); SoundEffect.TELEPORT_SOUND.playFor(p); teleporterUsers.remove(p.getUniqueId()); @@ -238,5 +276,4 @@ private void onTeleport(Player p, Location destination, boolean success, boolean } }); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java index 13c8b42561..e7d3d24803 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/Waypoint.java @@ -1,27 +1,24 @@ package io.github.thebusybiscuit.slimefun4.api.gps; +import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; import java.util.Objects; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.World.Environment; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter; - /** * A {@link Waypoint} represents a named {@link Location} that was created by a {@link Player}. * It can be used via a {@link Teleporter}. - * + * * @author TheBusyBiscuit - * + * * @see WaypointCreateEvent * @see GPSNetwork * @see TeleportationManager @@ -37,7 +34,7 @@ public class Waypoint { /** * This constructs a new {@link Waypoint} object. - * + * * @param profile * The owning {@link PlayerProfile} * @param id @@ -62,7 +59,7 @@ public Waypoint(PlayerProfile profile, String id, Location loc, String name) { /** * This returns the owner of the {@link Waypoint}. - * + * * @return The corresponding {@link PlayerProfile} */ @Nonnull @@ -72,7 +69,7 @@ public PlayerProfile getOwner() { /** * This method returns the unique identifier for this {@link Waypoint}. - * + * * @return The {@link Waypoint} id */ @Nonnull @@ -82,7 +79,7 @@ public String getId() { /** * This returns the name of this {@link Waypoint}. - * + * * @return The name of this {@link Waypoint} */ @Nonnull @@ -92,7 +89,7 @@ public String getName() { /** * This returns the {@link Location} of this {@link Waypoint} - * + * * @return The {@link Waypoint} {@link Location} */ @Nonnull @@ -102,7 +99,7 @@ public Location getLocation() { /** * This method returns whether this {@link Waypoint} is a Deathpoint. - * + * * @return Whether this is a Deathpoint */ public boolean isDeathpoint() { @@ -113,7 +110,7 @@ public boolean isDeathpoint() { * This method returns the {@link ItemStack} icon for this {@link Waypoint}. * The icon is dependent on the {@link Environment} the {@link Waypoint} is in * and whether it is a Deathpoint. - * + * * @return The {@link ItemStack} icon for this {@link Waypoint} */ @Nonnull @@ -139,7 +136,9 @@ public boolean equals(Object obj) { } Waypoint waypoint = (Waypoint) obj; - return profile.getUUID().equals(waypoint.getOwner().getUUID()) && id.equals(waypoint.getId()) && location.equals(waypoint.getLocation()) && name.equals(waypoint.getName()); + return profile.getUUID().equals(waypoint.getOwner().getUUID()) + && id.equals(waypoint.getId()) + && location.equals(waypoint.getLocation()) + && name.equals(waypoint.getName()); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java index 078403c9c2..f5bcb39ac8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/package-info.java @@ -2,4 +2,4 @@ * This package stores classes of the API that are related to the * {@link io.github.thebusybiscuit.slimefun4.api.gps.GPSNetwork}. */ -package io.github.thebusybiscuit.slimefun4.api.gps; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.gps; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java index 92a66e5a2f..cfe03cdc2f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java @@ -1,27 +1,24 @@ package io.github.thebusybiscuit.slimefun4.api.items; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask; import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.SlimefunArmorTask; - /** * This class serves as a way of checking whether a {@link Player} has changed their armor * between ticks. We do that by storing the hash of their armor and a reference to the * corresponding {@link SlimefunArmorPiece} if such a correlation exists. - * + * * This gives us a significant performance improvement as we only need to check for a * {@link SlimefunArmorPiece} if the item diverged in the first place. - * + * * @author TheBusyBiscuit * * @see SlimefunArmorPiece @@ -44,7 +41,7 @@ public HashedArmorpiece() { /** * This will update this {@link HashedArmorpiece} with the given {@link ItemStack} * and the corresponding {@link SlimefunItem} - * + * * @param stack * The new armorpiece to be stored in this {@link HashedArmorpiece} * @param item @@ -71,7 +68,7 @@ public void update(@Nullable ItemStack stack, @Nullable SlimefunItem item) { /** * This method checks whether the given {@link ItemStack} is no longer similar to the * one represented by this {@link HashedArmorpiece}. - * + * * @param stack * The {@link ItemStack} to compare * @return Whether the {@link HashedArmorpiece} and the given {@link ItemStack} mismatch @@ -91,7 +88,7 @@ public boolean hasDiverged(@Nullable ItemStack stack) { /** * Returns the {@link SlimefunArmorPiece} that corresponds to this {@link HashedArmorpiece}, * or an empty {@link Optional} - * + * * @return An {@link Optional} describing the result */ public @Nonnull Optional getItem() { @@ -100,7 +97,10 @@ public boolean hasDiverged(@Nullable ItemStack stack) { @Override public String toString() { - return "HashedArmorpiece {hash=" + hash + ",item=" + item.map(SlimefunItem::getId).orElse("null") + '}'; + return "HashedArmorpiece {hash=" + + hash + + ",item=" + + item.map(SlimefunItem::getId).orElse("null") + + '}'; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java index 0f70a46e6e..e543a24ce1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemGroup.java @@ -1,15 +1,19 @@ package io.github.thebusybiscuit.slimefun4.api.items; +import io.github.bakedlibs.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Keyed; @@ -19,22 +23,15 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * Represents an item group, which structure * multiple {@link SlimefunItem} in the {@link SlimefunGuide}. - * + * * @author TheBusyBiscuit * * @see LockedItemGroup * @see SeasonalItemGroup - * + * */ public class ItemGroup implements Keyed { @@ -50,7 +47,7 @@ public class ItemGroup implements Keyed { * Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier * and the given {@link ItemStack} as its display item. * The tier is set to a default value of {@code 3}. - * + * * @param key * The {@link NamespacedKey} that is used to identify this {@link ItemGroup} * @param item @@ -64,7 +61,7 @@ public ItemGroup(NamespacedKey key, ItemStack item) { /** * Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier * and the given {@link ItemStack} as its display item. - * + * * @param key * The {@link NamespacedKey} that is used to identify this {@link ItemGroup} * @param item @@ -100,7 +97,7 @@ public ItemGroup(NamespacedKey key, ItemStack item, int tier) { *

* By default, an {@link ItemGroup} is automatically registered when * a {@link SlimefunItem} was added to it. - * + * * @param addon * The {@link SlimefunAddon} that wants to register this {@link ItemGroup} */ @@ -120,7 +117,7 @@ public void register(@Nonnull SlimefunAddon addon) { /** * This method returns whether this {@link ItemGroup} has been registered yet. * More specifically: Whether {@link #register(SlimefunAddon)} was called or not. - * + * * @return Whether this {@link ItemGroup} has been registered */ public boolean isRegistered() { @@ -130,7 +127,7 @@ public boolean isRegistered() { /** * Returns the tier of this {@link ItemGroup}. * The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}. - * + * * @return the tier of this {@link ItemGroup} */ public int getTier() { @@ -140,7 +137,7 @@ public int getTier() { /** * This sets the tier of this {@link ItemGroup}. * The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}. - * + * * @param tier * The tier for this {@link ItemGroup} */ @@ -164,7 +161,7 @@ private void sortCategoriesByTier() { /** * This returns the {@link SlimefunAddon} which has registered this {@link ItemGroup}. * Or null if it has not been registered yet. - * + * * @return The {@link SlimefunAddon} or null if unregistered */ public final @Nullable SlimefunAddon getAddon() { @@ -173,7 +170,7 @@ private void sortCategoriesByTier() { /** * Adds the given {@link SlimefunItem} to this {@link ItemGroup}. - * + * * @param item * the {@link SlimefunItem} that should be added to this {@link ItemGroup} */ @@ -185,8 +182,13 @@ public void add(@Nonnull SlimefunItem item) { return; } - if (isRegistered() && !isCrossAddonItemGroup() && !item.getAddon().getName().equals(this.addon.getName())) { - item.warn("This item does not belong into ItemGroup " + this + " as that group belongs to " + this.addon.getName()); + if (isRegistered() + && !isCrossAddonItemGroup() + && !item.getAddon().getName().equals(this.addon.getName())) { + item.warn("This item does not belong into ItemGroup " + + this + + " as that group belongs to " + + this.addon.getName()); } items.add(item); @@ -194,7 +196,7 @@ public void add(@Nonnull SlimefunItem item) { /** * Removes the given {@link SlimefunItem} from this {@link ItemGroup}. - * + * * @param item * the {@link SlimefunItem} that should be removed from this {@link ItemGroup} */ @@ -206,10 +208,10 @@ public void remove(@Nonnull SlimefunItem item) { /** * This method returns a localized display item of this {@link ItemGroup} * for the specified {@link Player}. - * + * * @param p * The Player to create this {@link ItemStack} for - * + * * @return A localized display item for this {@link ItemGroup} */ public @Nonnull ItemStack getItem(@Nonnull Player p) { @@ -226,14 +228,19 @@ public void remove(@Nonnull SlimefunItem item) { meta.setDisplayName(ChatColor.YELLOW + name); } - meta.setLore(Arrays.asList("", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + meta.setLore(Arrays.asList( + "", + ChatColor.GRAY + + "\u21E8 " + + ChatColor.GREEN + + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); }); } /** * This method makes Walshy happy. * It adds a way to get the name of a {@link ItemGroup} without localization nor coloring. - * + * * @return The unlocalized name of this {@link ItemGroup} */ public @Nonnull String getUnlocalizedName() { @@ -243,10 +250,10 @@ public void remove(@Nonnull SlimefunItem item) { /** * This returns the localized display name of this {@link ItemGroup} for the given {@link Player}. * The method will fall back to {@link #getUnlocalizedName()} if no translation was found. - * + * * @param p * The {@link Player} who to translate the name for - * + * * @return The localized name of this {@link ItemGroup} */ public @Nonnull String getDisplayName(@Nonnull Player p) { @@ -261,7 +268,7 @@ public void remove(@Nonnull SlimefunItem item) { /** * Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}. - * + * * @return the list of SlimefunItems bound to this {@link ItemGroup} */ public @Nonnull List getItems() { @@ -270,10 +277,10 @@ public void remove(@Nonnull SlimefunItem item) { /** * This method returns whether a given {@link SlimefunItem} exists in this {@link ItemGroup}. - * + * * @param item * The {@link SlimefunItem} to find - * + * * @return Whether the given {@link SlimefunItem} was found in this {@link ItemGroup} */ public boolean contains(@Nullable SlimefunItem item) { @@ -285,10 +292,10 @@ public boolean contains(@Nullable SlimefunItem item) { * by the given {@link Player}. If an {@link ItemGroup} is not accessible, * it will not show up in the {@link SlimefunGuide} nor will items from this * {@link ItemGroup} show up in the guide search. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether this {@link ItemGroup} is accessible by the given {@link Player} */ public boolean isAccessible(@Nonnull Player p) { @@ -301,10 +308,10 @@ public boolean isAccessible(@Nonnull Player p) { * be visible. This includes {@link ItemGroup ItemGroups} where every {@link SlimefunItem} * is disabled. If an {@link ItemGroup} is not accessible by the {@link Player}, * see {@link #isAccessible(Player)}, this method will also return false. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether this {@link ItemGroup} is visible to the given {@link Player} */ public boolean isVisible(@Nonnull Player p) { @@ -371,17 +378,16 @@ public String toString() { /** * This method checks whether this {@link ItemGroup} will be hidden for the specified * {@link Player}. - * + * * Categories are hidden if all of their items have been disabled. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether this {@link ItemGroup} will be hidden to the given {@link Player} */ @Deprecated public boolean isHidden(@Nonnull Player p) { return !isVisible(p); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java index 251daefe14..d306fe7271 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemHandler.java @@ -1,9 +1,5 @@ package io.github.thebusybiscuit.slimefun4.api.items; -import java.util.Optional; - -import javax.annotation.Nonnull; - import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.BowShootHandler; @@ -11,11 +7,13 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import java.util.Optional; +import javax.annotation.Nonnull; /** * An {@link ItemHandler} represents a certain action that a {@link SlimefunItem} * can perform. - * + * * @author TheBusyBiscuit * * @see ItemUseHandler @@ -32,10 +30,10 @@ public interface ItemHandler { * This method is used to check whether a given {@link SlimefunItem} is compatible * with this {@link ItemHandler}, it will return an {@link IncompatibleItemHandlerException} * if the items are not compatible. - * + * * @param item * The {@link SlimefunItem} to validate - * + * * @return An {@link Optional} describing the result, it will contain an {@link IncompatibleItemHandlerException} * should there be an issue */ @@ -47,7 +45,7 @@ default Optional validate(@Nonnull SlimefunIte /** * This method returns the identifier for this {@link ItemHandler}. * We use a {@link Class} identifier to group Item Handlers together. - * + * * @return The {@link Class} identifier for this {@link ItemHandler} */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index bddcf03893..9d3199da24 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -1,20 +1,17 @@ package io.github.thebusybiscuit.slimefun4.api.items; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.List; import java.util.Objects; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * This class represents a Setting for a {@link SlimefunItem} that can be modified via * the {@code Items.yml} {@link Config} file. - * + * * @author TheBusyBiscuit * * @param @@ -31,7 +28,7 @@ public class ItemSetting { /** * This creates a new {@link ItemSetting} with the given key and default value - * + * * @param item * The {@link SlimefunItem} this {@link ItemSetting} belongs to * @param key @@ -53,10 +50,10 @@ public ItemSetting(SlimefunItem item, String key, T defaultValue) { /** * This method checks if a given input would be valid as a value for this * {@link ItemSetting}. You can override this method to implement your own checks. - * + * * @param input * The input value to validate - * + * * @return Whether the given input was valid */ public boolean validateInput(T input) { @@ -67,7 +64,7 @@ public boolean validateInput(T input) { * This method updates this {@link ItemSetting} with the given value. * Override this method to catch changes of a value. * A value may never be null. - * + * * @param newValue * The new value for this {@link ItemSetting} */ @@ -83,7 +80,7 @@ public void update(@Nonnull T newValue) { /** * This returns the key of this {@link ItemSetting}. - * + * * @return The key under which this setting is stored (relative to the {@link SlimefunItem}) */ public @Nonnull String getKey() { @@ -92,7 +89,7 @@ public void update(@Nonnull T newValue) { /** * This returns the associated {@link SlimefunItem} for this {@link ItemSetting}. - * + * * @return The associated {@link SlimefunItem} */ protected @Nonnull SlimefunItem getItem() { @@ -101,7 +98,7 @@ public void update(@Nonnull T newValue) { /** * This returns the current value of this {@link ItemSetting}. - * + * * @return The current value */ public @Nonnull T getValue() { @@ -128,7 +125,7 @@ public void update(@Nonnull T newValue) { /** * This returns the default value of this {@link ItemSetting}. - * + * * @return The default value */ public @Nonnull T getDefaultValue() { @@ -137,10 +134,10 @@ public void update(@Nonnull T newValue) { /** * This method checks if this {@link ItemSetting} stores the given data type. - * + * * @param c * The class of data type you want to compare - * + * * @return Whether this {@link ItemSetting} stores the given type */ public boolean isType(@Nonnull Class c) { @@ -150,7 +147,7 @@ public boolean isType(@Nonnull Class c) { /** * This is an error message which should provide further context on what values * are allowed. - * + * * @return An error message which is displayed when this {@link ItemSetting} is misconfigured. */ protected @Nonnull String getErrorMessage() { @@ -160,7 +157,7 @@ public boolean isType(@Nonnull Class c) { /** * This method is called by a {@link SlimefunItem} which wants to load its {@link ItemSetting} * from the {@link Config} file. - * + * */ @SuppressWarnings("unchecked") public void reload() { @@ -169,7 +166,8 @@ public void reload() { Slimefun.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue()); Object configuredValue = Slimefun.getItemCfg().getValue(item.getId() + '.' + getKey()); - if (defaultValue.getClass().isInstance(configuredValue) || (configuredValue instanceof List && defaultValue instanceof List)) { + if (defaultValue.getClass().isInstance(configuredValue) + || (configuredValue instanceof List && defaultValue instanceof List)) { // We can do an unsafe cast here, we did an isInstance(...) check before! T newValue = (T) configuredValue; @@ -177,25 +175,38 @@ public void reload() { this.value = newValue; } else { // @formatter:off - item.warn( - "发现在 Items.yml 中有无效的物品设置!" + - "\n 在 \"" + item.getId() + "." + getKey() + "\"" + - "\n " + configuredValue + " 不是一个有效值!" + - "\n" + getErrorMessage() - ); + item.warn("发现在 Items.yml 中有无效的物品设置!" + + "\n 在 \"" + + item.getId() + + "." + + getKey() + + "\"" + + "\n " + + configuredValue + + " 不是一个有效值!" + + "\n" + + getErrorMessage()); // @formatter:on } } else { this.value = defaultValue; - String found = configuredValue == null ? "null" : configuredValue.getClass().getSimpleName(); + String found = configuredValue == null + ? "null" + : configuredValue.getClass().getSimpleName(); // @formatter:off - item.warn( - "发现在 Items.yml 中有无效的物品设置!" + - "\n请只设置有效的值." + - "\n 在 \"" + item.getId() + "." + getKey() + "\"" + - "\n 期望值为 \"" + defaultValue.getClass().getSimpleName() + "\" 但填写了: \"" + found + "\"" - ); + item.warn("发现在 Items.yml 中有无效的物品设置!" + + "\n请只设置有效的值." + + "\n 在 \"" + + item.getId() + + "." + + getKey() + + "\"" + + "\n 期望值为 \"" + + defaultValue.getClass().getSimpleName() + + "\" 但填写了: \"" + + found + + "\""); // @formatter:on } } @@ -203,7 +214,14 @@ public void reload() { @Override public String toString() { T currentValue = this.value != null ? this.value : defaultValue; - return getClass().getSimpleName() + " {" + getKey() + " = " + currentValue + " (default: " + getDefaultValue() + ")"; + return getClass().getSimpleName() + + " {" + + getKey() + + " = " + + currentValue + + " (default: " + + getDefaultValue() + + ")"; } @Override @@ -220,5 +238,4 @@ public final boolean equals(Object obj) { return false; } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java index e21bc31a14..5f3c0da814 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSpawnReason.java @@ -1,8 +1,5 @@ package io.github.thebusybiscuit.slimefun4.api.items; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemSpawnEvent; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.core.networks.cargo.CargoNet; @@ -11,6 +8,8 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.seasonal.EasterEgg; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.PickaxeOfContainment; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; /** * This enum holds the different reasons as to why we may need to spawn an item. @@ -65,5 +64,4 @@ public enum ItemSpawnReason { * Other reasons we did not account for. */ MISC; - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java index 0d5f132205..32f5f942a0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemState.java @@ -30,5 +30,4 @@ public enum ItemState { * {@link VanillaItem}. */ VANILLA_FALLBACK; - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java index a4a74e686c..95e908a81e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItem.java @@ -1,8 +1,6 @@ package io.github.thebusybiscuit.slimefun4.api.items; import com.xzavier0722.mc.plugin.slimefun4.storage.controller.SlimefunBlockData; -import com.xzavier0722.mc.plugin.slimefun4.storage.util.StorageCacheUtils; -import io.github.bakedlibs.dough.blocks.ChunkPosition; import io.github.bakedlibs.dough.collections.OptionalMap; import io.github.bakedlibs.dough.items.ItemUtils; import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; @@ -20,36 +18,27 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable; import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; -import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.handlers.GlobalItemHandler; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; - import java.text.MessageFormat; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; import java.util.HashSet; -import java.util.Map; import java.util.Optional; import java.util.Set; -import java.util.Collection; -import java.util.Arrays; -import java.util.HashMap; import java.util.function.Consumer; import java.util.logging.Level; import java.util.logging.Logger; import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import org.apache.commons.lang.Validate; -import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.entity.Player; @@ -63,14 +52,16 @@ * This class defines the behaviours of the item, you can assign an {@link ItemHandler} * to give the item functionality. * In contrast to that the {@link SlimefunItemStack} defines the look and feel of the item. - *

+ * * Remember to call {@link #register(SlimefunAddon)} on your {@link SlimefunItem} for it * to appear in the {@link SlimefunGuide}. * * @author TheBusyBiscuit * @author Poslovitch + * * @see SlimefunItemStack * @see SlimefunAddon + * */ public class SlimefunItem implements Placeable { @@ -126,10 +117,14 @@ public class SlimefunItem implements Placeable { /** * This creates a new {@link SlimefunItem} from the given arguments. * - * @param itemGroup The {@link ItemGroup} this {@link SlimefunItem} belongs to - * @param item The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem} - * @param recipeType the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted - * @param recipe An Array representing the recipe of this {@link SlimefunItem} + * @param itemGroup + * The {@link ItemGroup} this {@link SlimefunItem} belongs to + * @param item + * The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem} + * @param recipeType + * the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted + * @param recipe + * An Array representing the recipe of this {@link SlimefunItem} */ @ParametersAreNonnullByDefault public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -139,14 +134,24 @@ public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType reci /** * This creates a new {@link SlimefunItem} from the given arguments. * - * @param itemGroup The {@link ItemGroup} this {@link SlimefunItem} belongs to - * @param item The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem} - * @param recipeType the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted - * @param recipe An Array representing the recipe of this {@link SlimefunItem} - * @param recipeOutput The result of crafting this item + * @param itemGroup + * The {@link ItemGroup} this {@link SlimefunItem} belongs to + * @param item + * The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem} + * @param recipeType + * the {@link RecipeType} that determines how this {@link SlimefunItem} is crafted + * @param recipe + * An Array representing the recipe of this {@link SlimefunItem} + * @param recipeOutput + * The result of crafting this item */ @ParametersAreNonnullByDefault - public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) { + public SlimefunItem( + ItemGroup itemGroup, + SlimefunItemStack item, + RecipeType recipeType, + ItemStack[] recipe, + @Nullable ItemStack recipeOutput) { Validate.notNull(itemGroup, "'itemGroup' is not allowed to be null!"); Validate.notNull(item, "'item' is not allowed to be null!"); Validate.notNull(recipeType, "'recipeType' is not allowed to be null!"); @@ -187,7 +192,7 @@ protected SlimefunItem(ItemGroup itemGroup, ItemStack item, String id, RecipeTyp * This method returns the {@link ItemState} this {@link SlimefunItem} * is currently in. This can be used to determine whether a {@link SlimefunItem} * is enabled or disabled. - *

+ * * {@link VanillaItem} represents a special case here. * * @return The {@link ItemState} of this {@link SlimefunItem} @@ -367,7 +372,9 @@ public boolean isDisabled() { */ public boolean isDisabledIn(@Nonnull World world) { if (state == ItemState.UNREGISTERED) { - error("isDisabled(World) cannot be called before registering the item", new UnregisteredItemException(this)); + error( + "isDisabled(World) cannot be called before registering the item", + new UnregisteredItemException(this)); return false; } @@ -502,16 +509,9 @@ public void enable() { Slimefun.getRegistry().getRadioactiveItems().add(this); } - // enable ticking block - Slimefun.getRegistry().getTickerBlocks().add(getId()); - state = ItemState.ENABLED; Slimefun.getRegistry().getEnabledSlimefunItems().add(this); - - if (!hidden) { - itemGroup.add(this); - } } /** @@ -528,10 +528,6 @@ public void disable() { state = ItemState.DISABLED; Slimefun.getRegistry().getEnabledSlimefunItems().remove(this); - - if (!hidden) { - itemGroup.remove(this); - } } /** @@ -552,8 +548,10 @@ private final void onEnable() { // Check for an illegal stack size if (itemStackTemplate.getAmount() != 1) { // @formatter:off - warn("This item has an illegal stack size: " + itemStackTemplate.getAmount() - + ". An Item size of 1 is recommended. Please inform the author(s) of " + addon.getName() + warn("This item has an illegal stack size: " + + itemStackTemplate.getAmount() + + ". An Item size of 1 is recommended. Please inform the author(s) of " + + addon.getName() + " to fix this. Crafting Results with amounts of higher should be handled" + " via the recipeOutput parameter!"); // @formatter:on @@ -600,7 +598,7 @@ private void loadItemHandlers() { /** * This method returns whether the original {@link SlimefunItemStack} of this * {@link SlimefunItem} is immutable. - *

+ * * If true is returned, then any changes to the original {@link SlimefunItemStack} * will be rejected with a {@link WrongItemStackException}. * This ensures integrity so developers don't accidentally damage the wrong {@link ItemStack}. @@ -614,7 +612,8 @@ protected boolean isItemStackImmutable() { /** * This method checks if the dependencies have been set up correctly. * - * @param addon The {@link SlimefunAddon} trying to register this {@link SlimefunItem} + * @param addon + * The {@link SlimefunAddon} trying to register this {@link SlimefunItem} */ private void checkDependencies(@Nonnull SlimefunAddon addon) { if (!addon.hasDependency("Slimefun")) { @@ -636,10 +635,11 @@ private void checkForConflicts() { /** * This method checks recursively for all {@link Class} parents to look for any {@link Deprecated} * elements. - *

+ * * If a {@link Deprecated} element was found, a warning message will be printed. * - * @param c The {@link Class} from which to start this operation. + * @param c + * The {@link Class} from which to start this operation. */ private void checkForDeprecations(@Nullable Class c) { if (Slimefun.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) { @@ -659,13 +659,17 @@ private void checkForDeprecations(@Nullable Class c) { if (c != null) { // Check if this Class is deprecated if (c.isAnnotationPresent(Deprecated.class)) { - warn("The inherited Class \"" + c.getName() + "\" has been deprecated. Check the documentation for more details!"); + warn("The inherited Class \"" + + c.getName() + + "\" has been deprecated. Check the documentation for more details!"); } for (Class parent : c.getInterfaces()) { // Check if this Interface is deprecated if (parent.isAnnotationPresent(Deprecated.class)) { - warn("The implemented Interface \"" + parent.getName() + "\" has been deprecated. Check the documentation for more details!"); + warn("The implemented Interface \"" + + parent.getName() + + "\" has been deprecated. Check the documentation for more details!"); } } @@ -679,7 +683,8 @@ private void checkForDeprecations(@Nullable Class c) { * You don't have to call this method if your {@link SlimefunItem} was linked to your {@link Research} * using {@link Research#addItems(SlimefunItem...)} * - * @param research The new {@link Research} for this {@link SlimefunItem}, or null + * @param research + * The new {@link Research} for this {@link SlimefunItem}, or null */ public void setResearch(@Nullable Research research) { if (this.research != null) { @@ -696,7 +701,8 @@ public void setResearch(@Nullable Research research) { /** * Sets the recipe for this {@link SlimefunItem}. * - * @param recipe The recipe for this {@link ItemStack} + * @param recipe + * The recipe for this {@link ItemStack} */ public void setRecipe(@Nonnull ItemStack[] recipe) { if (recipe == null || recipe.length != 9) { @@ -709,7 +715,8 @@ public void setRecipe(@Nonnull ItemStack[] recipe) { /** * Sets the {@link RecipeType} for this {@link SlimefunItem}. * - * @param type The {@link RecipeType} for this {@link SlimefunItem} + * @param type + * The {@link RecipeType} for this {@link SlimefunItem} */ public void setRecipeType(@Nonnull RecipeType type) { Validate.notNull(type, "The RecipeType is not allowed to be null!"); @@ -719,7 +726,8 @@ public void setRecipeType(@Nonnull RecipeType type) { /** * This sets the {@link ItemGroup} in which this {@link SlimefunItem} will be displayed. * - * @param itemGroup The new {@link ItemGroup} + * @param itemGroup + * The new {@link ItemGroup} */ public void setItemGroup(@Nonnull ItemGroup itemGroup) { Validate.notNull(itemGroup, "The ItemGroup is not allowed to be null!"); @@ -734,7 +742,8 @@ public void setItemGroup(@Nonnull ItemGroup itemGroup) { * This method will set the result of crafting this {@link SlimefunItem}. * If null is passed, then it will use the default item as the recipe result. * - * @param output The {@link ItemStack} that will be the result of crafting this {@link SlimefunItem} + * @param output + * The {@link ItemStack} that will be the result of crafting this {@link SlimefunItem} */ public void setRecipeOutput(@Nullable ItemStack output) { this.recipeOutput = output; @@ -743,11 +752,12 @@ public void setRecipeOutput(@Nullable ItemStack output) { /** * This method returns whether or not this {@link SlimefunItem} is allowed to * be used in a Crafting Table. - *

+ * * Items of type {@link VanillaItem} may be used in workbenches for example. * - * @return Whether this {@link SlimefunItem} may be used in a Workbench. * @see #setUseableInWorkbench(boolean) + * + * @return Whether this {@link SlimefunItem} may be used in a Workbench. */ public boolean isUseableInWorkbench() { return useableInWorkbench; @@ -757,7 +767,9 @@ public boolean isUseableInWorkbench() { * This sets whether or not this {@link SlimefunItem} is allowed to be * used in a normal Crafting Table. * - * @param useable Whether this {@link SlimefunItem} should be useable in a workbench + * @param useable + * Whether this {@link SlimefunItem} should be useable in a workbench + * * @return This instance of {@link SlimefunItem} */ public @Nonnull SlimefunItem setUseableInWorkbench(boolean useable) { @@ -770,7 +782,9 @@ public boolean isUseableInWorkbench() { * This method checks whether the provided {@link ItemStack} represents * this {@link SlimefunItem}. * - * @param item The {@link ItemStack} to compare + * @param item + * The {@link ItemStack} to compare + * * @return Whether the given {@link ItemStack} represents this {@link SlimefunItem} */ public boolean isItem(@Nullable ItemStack item) { @@ -809,7 +823,8 @@ public void load() { * This method will add any given {@link ItemHandler} to this {@link SlimefunItem}. * Note that this will not work after the {@link SlimefunItem} was registered. * - * @param handlers Any {@link ItemHandler} that should be added to this {@link SlimefunItem} + * @param handlers + * Any {@link ItemHandler} that should be added to this {@link SlimefunItem} */ public final void addItemHandler(ItemHandler... handlers) { Validate.notEmpty(handlers, "You cannot add zero handlers..."); @@ -817,7 +832,8 @@ public final void addItemHandler(ItemHandler... handlers) { // Make sure they are added before the item was registered. if (state != ItemState.UNREGISTERED) { - throw new UnsupportedOperationException("You cannot add an ItemHandler after the SlimefunItem was registered."); + throw new UnsupportedOperationException( + "You cannot add an ItemHandler after the SlimefunItem was registered."); } for (ItemHandler handler : handlers) { @@ -836,18 +852,21 @@ public final void addItemHandler(ItemHandler... handlers) { * This method will add any given {@link ItemSetting} to this {@link SlimefunItem}. * Note that this will not work after the {@link SlimefunItem} was registered. * - * @param settings Any {@link ItemSetting} that should be added to this {@link SlimefunItem} + * @param settings + * Any {@link ItemSetting} that should be added to this {@link SlimefunItem} */ public final void addItemSetting(ItemSetting... settings) { Validate.notEmpty(settings, "You cannot add zero settings..."); Validate.noNullElements(settings, "You cannot add any 'null' ItemSettings!"); if (state != ItemState.UNREGISTERED) { - throw new UnsupportedOperationException("You cannot add an ItemSetting after the SlimefunItem was registered."); + throw new UnsupportedOperationException( + "You cannot add an ItemSetting after the SlimefunItem was registered."); } if (this instanceof NotConfigurable) { - throw new UnsupportedOperationException("This Item has been marked as NotConfigurable and cannot accept Item Settings!"); + throw new UnsupportedOperationException( + "This Item has been marked as NotConfigurable and cannot accept Item Settings!"); } for (ItemSetting setting : settings) { @@ -855,7 +874,8 @@ public final void addItemSetting(ItemSetting... settings) { // Prevent two Item Settings with the same key for (ItemSetting existingSetting : itemSettings) { if (existingSetting.getKey().equals(setting.getKey())) { - throw new IllegalArgumentException("This Item has already an ItemSetting with this key: " + setting.getKey()); + throw new IllegalArgumentException( + "This Item has already an ItemSetting with this key: " + setting.getKey()); } } @@ -887,11 +907,12 @@ public void postRegister() { * This method will assign the given wiki page to this Item. * Note that you only need to provide the page name itself, * the URL to our wiki is prepended automatically. - *

+ * * 返回非官方中文Wiki地址 * 下游应使用 {@link SlimefunItem#addWikiPage(String)} 来添加Wiki页面 * - * @param page The associated wiki page + * @param page + * The associated wiki page */ @Deprecated public final void addOfficialWikipage(@Nonnull String page) { @@ -922,8 +943,9 @@ public final void addWikiPage(@Nonnull String page) { * This method returns the wiki page that has been assigned to this item. * It will return null, if no wiki page was found. * - * @return This item's wiki page * @see SlimefunItem#addWikiPage(String) + * + * @return This item's wiki page */ public @Nonnull Optional getWikipage() { return wikiURL; @@ -937,7 +959,9 @@ public final void addWikiPage(@Nonnull String page) { */ public final @Nonnull String getItemName() { if (itemStackTemplate instanceof SlimefunItemStack) { - Optional name = ((SlimefunItemStack) itemStackTemplate).getItemMetaSnapshot().getDisplayName(); + Optional name = ((SlimefunItemStack) itemStackTemplate) + .getItemMetaSnapshot() + .getDisplayName(); if (name.isPresent()) { return name.get(); @@ -960,9 +984,13 @@ public final void addWikiPage(@Nonnull String page) { * This method calls every {@link ItemHandler} of the given {@link Class} * and performs the action as specified via the {@link Consumer}. * - * @param c The {@link Class} of the {@link ItemHandler} to call. - * @param callable A {@link Consumer} that is called for any found {@link ItemHandler}. - * @param The type of {@link ItemHandler} to call. + * @param c + * The {@link Class} of the {@link ItemHandler} to call. + * @param callable + * A {@link Consumer} that is called for any found {@link ItemHandler}. + * @param + * The type of {@link ItemHandler} to call. + * * @return Whether or not an {@link ItemHandler} was found. */ @ParametersAreNonnullByDefault @@ -996,7 +1024,14 @@ public String toString() { if (addon == null) { return getClass().getSimpleName() + " - '" + id + "'"; } else { - return getClass().getSimpleName() + " - '" + id + "' (" + addon.getName() + " v" + addon.getPluginVersion() + ')'; + return getClass().getSimpleName() + + " - '" + + id + + "' (" + + addon.getName() + + " v" + + addon.getPluginVersion() + + ')'; } } @@ -1015,7 +1050,8 @@ public String toString() { * from this {@link SlimefunItem}, the message will be sent using the {@link Logger} * of the {@link SlimefunAddon} which registered this {@link SlimefunItem}. * - * @param message The message to send + * @param message + * The message to send */ @ParametersAreNonnullByDefault public void info(String message) { @@ -1030,7 +1066,8 @@ public void info(String message) { * this {@link SlimefunItem}, the warning will be sent using the {@link Logger} * of the {@link SlimefunAddon} which registered this {@link SlimefunItem}. * - * @param message The message to send + * @param message + * The message to send */ @ParametersAreNonnullByDefault public void warn(String message) { @@ -1049,13 +1086,17 @@ public void warn(String message) { * This will throw a {@link Throwable} to the console and signal that * this was caused by this {@link SlimefunItem}. * - * @param message The message to display alongside this Stacktrace - * @param throwable The {@link Throwable} to throw as a stacktrace. + * @param message + * The message to display alongside this Stacktrace + * @param throwable + * The {@link Throwable} to throw as a stacktrace. */ @ParametersAreNonnullByDefault public void error(String message, Throwable throwable) { Validate.notNull(addon, "Cannot send an error for an unregistered item!"); - addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[]{id, addon.getName(), addon.getPluginVersion()}); + addon.getLogger().log(Level.SEVERE, "Item \"{0}\" from {1} v{2} has caused an Error!", new Object[] { + id, addon.getName(), addon.getPluginVersion() + }); if (addon.getBugTrackerURL() != null) { // We can prompt the server operator to report it to the addon's bug tracker @@ -1074,7 +1115,8 @@ public void error(String message, Throwable throwable) { * This method informs the given {@link Player} that this {@link SlimefunItem} * will be removed soon. * - * @param player The {@link Player} to inform. + * @param player + * The {@link Player} to inform. */ @ParametersAreNonnullByDefault public void sendDeprecationWarning(Player player) { @@ -1092,12 +1134,15 @@ public void sendDeprecationWarning(Player player) { *

  • The {@link Player} has the required {@link Permission} (if present) *
  • The {@link Player} has unlocked the required {@link Research} (if present) * - *

    + * * If any of these conditions evaluate to false, then an optional message will be * sent to the {@link Player}. * - * @param p The {@link Player} to check - * @param sendMessage Whether to send that {@link Player} a message response. + * @param p + * The {@link Player} to check + * @param sendMessage + * Whether to send that {@link Player} a message response. + * * @return Whether this {@link Player} is able to use this {@link SlimefunItem}. */ public boolean canUse(@Nonnull Player p, boolean sendMessage) { @@ -1144,7 +1189,8 @@ public boolean canUse(@Nonnull Player p, boolean sendMessage) { * required Research to use this SlimefunItem. */ if (sendMessage && !(this instanceof VanillaItem)) { - Slimefun.getLocalization().sendMessage(p, "messages.not-researched", true, s -> s.replace("%item%", getItemName())); + Slimefun.getLocalization() + .sendMessage(p, "messages.not-researched", true, s -> s.replace("%item%", getItemName())); } return false; @@ -1178,7 +1224,8 @@ public final int hashCode() { /** * Retrieve a {@link SlimefunItem} by its id. * - * @param id The id of the {@link SlimefunItem} + * @param id + * The id of the {@link SlimefunItem} * @return The {@link SlimefunItem} associated with that id. Null if non-existent */ public static @Nullable SlimefunItem getById(@Nonnull String id) { @@ -1188,7 +1235,8 @@ public final int hashCode() { /** * Retrieve a {@link SlimefunItem} from an {@link ItemStack}. * - * @param item The {@link ItemStack} to check + * @param item + * The {@link ItemStack} to check * @return The {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise null */ public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) { @@ -1216,4 +1264,4 @@ public final int hashCode() { public boolean loadDataByDefault() { return ticking; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java index 5604cdcfa8..bc85e022f7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/SlimefunItemStack.java @@ -1,5 +1,14 @@ package io.github.thebusybiscuit.slimefun4.api.items; +import io.github.bakedlibs.dough.common.CommonPatterns; +import io.github.bakedlibs.dough.items.ItemMetaSnapshot; +import io.github.bakedlibs.dough.skins.PlayerHead; +import io.github.bakedlibs.dough.skins.PlayerSkin; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException; +import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Base64; @@ -7,10 +16,8 @@ import java.util.Locale; import java.util.Optional; import java.util.function.Consumer; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Color; @@ -23,20 +30,10 @@ import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.bakedlibs.dough.items.ItemMetaSnapshot; -import io.github.bakedlibs.dough.skins.PlayerHead; -import io.github.bakedlibs.dough.skins.PlayerSkin; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException; -import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; - /** * The {@link SlimefunItemStack} functions as the base for any * {@link SlimefunItem}. - * + * * @author TheBusyBiscuit * @author Walshy * @@ -53,10 +50,12 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item) { super(item); Validate.notNull(id, "The Item id must never be null!"); - Validate.isTrue(id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')"); + Validate.isTrue( + id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')"); if (Slimefun.instance() == null) { - throw new PrematureCodeException("A SlimefunItemStack must never be be created before your Plugin was enabled."); + throw new PrematureCodeException( + "A SlimefunItemStack must never be be created before your Plugin was enabled."); } this.id = id; @@ -81,7 +80,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Co this(id, new ItemStack(type), consumer); } - public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer consumer) { + public SlimefunItemStack( + @Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer consumer) { this(id, type, meta -> { if (name != null) { meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); @@ -112,7 +112,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable S this(id, new ItemStack(type), name, lore); } - public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) { + public SlimefunItemStack( + @Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) { this(id, type, im -> { if (name != null) { im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); @@ -138,7 +139,12 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Co }); } - public SlimefunItemStack(@Nonnull String id, @Nonnull Color color, @Nonnull PotionEffect effect, @Nullable String name, String... lore) { + public SlimefunItemStack( + @Nonnull String id, + @Nonnull Color color, + @Nonnull PotionEffect effect, + @Nullable String name, + String... lore) { this(id, Material.POTION, im -> { if (name != null) { im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); @@ -179,7 +185,8 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull HeadTexture head, @Nullabl this(id, head.getTexture(), name, lore); } - public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nullable String name, @Nonnull Consumer consumer) { + public SlimefunItemStack( + @Nonnull String id, @Nonnull String texture, @Nullable String name, @Nonnull Consumer consumer) { this(id, getSkull(id, texture), meta -> { if (name != null) { meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name)); @@ -198,7 +205,7 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nonnull C /** * Returns the id that was given to this {@link SlimefunItemStack}. - * + * * @return The {@link SlimefunItem} id for this {@link SlimefunItemStack} */ public final @Nonnull String getItemId() { @@ -218,18 +225,17 @@ public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nonnull C /** * This method returns the associated {@link SlimefunItem} and casts it to the provided * {@link Class}. - * + * * If no item was found or the found {@link SlimefunItem} is not of the requested type, * the method will return null. - * + * * @param * The type of {@link SlimefunItem} to cast this to * @param type * The {@link Class} of the target {@link SlimefunItem} - * + * * @return The {@link SlimefunItem} this {@link SlimefunItem} represents, casted to the given type */ - public @Nullable T getItem(@Nonnull Class type) { SlimefunItem item = getItem(); return type.isInstance(item) ? type.cast(item) : null; @@ -298,10 +304,12 @@ public void lock() { if (texture.startsWith("ey")) { return texture; } else if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) { - String value = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}"; + String value = + "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}"; return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8)); } else { - throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); + throw new IllegalArgumentException( + "The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java index 92f137dcfc..98eb2214f9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/FlexItemGroup.java @@ -1,26 +1,23 @@ package io.github.thebusybiscuit.slimefun4.api.items.groups; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import java.util.List; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; - /** * A {@link FlexItemGroup} is a {@link ItemGroup} inside the {@link SlimefunGuide} that can * be completely modified. * It cannot hold any {@link SlimefunItem} but can be completely overridden * to perform any action upon being opened. - * + * * @author TheBusyBiscuit * */ @@ -49,14 +46,14 @@ public final boolean isVisible(@Nonnull Player p) { /** * This method returns whether this {@link FlexItemGroup} is visible under the given context. * Implementing this method gives full flexibility over who can see the ItemGroup when and where. - * + * * @param p * The {@link Player} who opened his {@link SlimefunGuide} * @param profile * The {@link PlayerProfile} of the {@link Player} * @param layout * The {@link SlimefunGuideMode} in which this {@link FlexItemGroup} is viewed - * + * * @return Whether to display this {@link FlexItemGroup} */ @ParametersAreNonnullByDefault @@ -66,7 +63,7 @@ public final boolean isVisible(@Nonnull Player p) { * This method is called when a {@link Player} opens this {@link FlexItemGroup}. * This is an abstract method which needs to be implemented in order to determine what this * {@link FlexItemGroup} should actually do as it cannot hold any items. - * + * * @param p * The {@link Player} who wants to open this {@link FlexItemGroup} * @param profile @@ -95,5 +92,4 @@ public final boolean contains(SlimefunItem item) { public final void remove(@Nonnull SlimefunItem item) { throw new UnsupportedOperationException("A FlexItemGroup has no items, so there is nothing remove!"); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java index 826ddbf301..5787dbd80b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/LockedItemGroup.java @@ -1,36 +1,33 @@ package io.github.thebusybiscuit.slimefun4.api.items.groups; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * Represents a {@link ItemGroup} that cannot be opened until the parent group(s) * are fully unlocked. *

    * See {@link ItemGroup} for the complete documentation. - * + * * @author TheBusyBiscuit - * + * * @see ItemGroup * @see SeasonalItemGroup - * + * */ public class LockedItemGroup extends ItemGroup { @@ -40,14 +37,14 @@ public class LockedItemGroup extends ItemGroup { /** * The basic constructor for a LockedItemGroup. * Like {@link ItemGroup}, the default tier is automatically set to 3. - * + * * @param key * A unique identifier for this group * @param item * The display item for this group * @param parents * The parent categories for this group - * + * */ @ParametersAreNonnullByDefault public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... parents) { @@ -56,7 +53,7 @@ public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... paren /** * The constructor for a LockedItemGroup. - * + * * @param key * A unique identifier for this group * @param item @@ -65,7 +62,7 @@ public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... paren * The tier of this group * @param parents * The parent categories for this group - * + * */ @ParametersAreNonnullByDefault public LockedItemGroup(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) { @@ -94,15 +91,19 @@ public void register(@Nonnull SlimefunAddon addon) { } for (NamespacedKey key : namespacedKeys) { - Slimefun.logger().log(Level.INFO, "Parent \"{0}\" for LockedItemGroup \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() }); + Slimefun.logger() + .log( + Level.INFO, + "Parent \"{0}\" for LockedItemGroup \"{1}\" was not found, probably just disabled.", + new Object[] {key, getKey()}); } } /** * Gets the list of parent item groups for this {@link LockedItemGroup}. - * + * * @return the list of parent item groups - * + * * @see #addParent(ItemGroup) * @see #removeParent(ItemGroup) */ @@ -112,7 +113,7 @@ public void register(@Nonnull SlimefunAddon addon) { /** * Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}. - * + * * @param group * The {@link ItemGroup} to add as a parent * @@ -121,7 +122,9 @@ public void register(@Nonnull SlimefunAddon addon) { */ public void addParent(ItemGroup group) { if (group == this || group == null) { - throw new IllegalArgumentException("ItemGroup '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent."); + throw new IllegalArgumentException("ItemGroup '" + + item.getItemMeta().getDisplayName() + + "' cannot be a parent of itself or have a 'null' parent."); } parents.add(group); @@ -129,10 +132,10 @@ public void addParent(ItemGroup group) { /** * Removes a {@link ItemGroup} from the parents of this {@link LockedItemGroup}. - * + * * @param group * The {@link ItemGroup} to remove from the parents of this {@link LockedItemGroup} - * + * * @see #getParents() * @see #addParent(ItemGroup) */ @@ -142,12 +145,12 @@ public void removeParent(@Nonnull ItemGroup group) { /** * Checks if the {@link Player} has fully unlocked all parent categories. - * + * * @param p * The {@link Player} to check * @param profile * The {@link PlayerProfile} that belongs to the given {@link Player} - * + * * @return Whether the {@link Player} has fully completed all parent categories, otherwise false */ public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) { @@ -157,7 +160,9 @@ public boolean hasUnlocked(@Nonnull Player p, @Nonnull PlayerProfile profile) { for (ItemGroup parent : parents) { for (SlimefunItem item : parent.getItems()) { // Check if the Player has researched every item (if the item is enabled) - if (!item.isDisabledIn(p.getWorld()) && item.hasResearch() && !profile.hasUnlocked(item.getResearch())) { + if (!item.isDisabledIn(p.getWorld()) + && item.hasResearch() + && !profile.hasUnlocked(item.getResearch())) { return false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java index 9a928c8be1..a49d5316b6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/NestedItemGroup.java @@ -1,17 +1,5 @@ package io.github.thebusybiscuit.slimefun4.api.items.groups; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory; @@ -21,8 +9,16 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; - +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; +import org.apache.commons.lang.Validate; +import org.bukkit.ChatColor; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; public class NestedItemGroup extends FlexItemGroup { @@ -41,7 +37,7 @@ public NestedItemGroup(NamespacedKey key, ItemStack item, int tier) { /** * This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}. - * + * * @param group * The {@link SubItemGroup} to add. */ @@ -53,7 +49,7 @@ public void addSubGroup(@Nonnull SubItemGroup group) { /** * This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present). - * + * * @param group * The {@link SubItemGroup} to remove. */ @@ -84,13 +80,17 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, } ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.main")); - SurvivalSlimefunGuide guide = (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode); + SurvivalSlimefunGuide guide = + (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode); menu.setEmptySlotsClickable(false); menu.addMenuOpeningHandler(SoundEffect.GUIDE_BUTTON_CLICK_SOUND::playFor); guide.createHeader(p, profile, menu); - menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); + menu.addItem( + 1, + new CustomItemStack(ChestMenuUtils.getBackButton( + p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); menu.addMenuClickHandler(1, (pl, s, is, action) -> { SlimefunGuide.openMainMenu(profile, mode, history.getMainMenuPage()); return false; @@ -143,5 +143,4 @@ private void openGuide(Player p, PlayerProfile profile, SlimefunGuideMode mode, menu.open(p); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java index c61212c265..bbfed63d87 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SeasonalItemGroup.java @@ -1,24 +1,21 @@ package io.github.thebusybiscuit.slimefun4.api.items.groups; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import java.time.LocalDate; import java.time.Month; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; - /** * Represents a {@link ItemGroup} that is only displayed in the Guide during * a specified {@link Month}. - * + * * @author TheBusyBiscuit - * + * * @see ItemGroup * @see LockedItemGroup */ @@ -28,7 +25,7 @@ public class SeasonalItemGroup extends ItemGroup { /** * The constructor for a {@link SeasonalItemGroup}. - * + * * @param key * The {@link NamespacedKey} that is used to identify this {@link ItemGroup} * @param month @@ -48,7 +45,7 @@ public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack ite /** * This method returns the {@link Month} in which this {@link SeasonalItemGroup} will appear. - * + * * @return the {@link Month} in which this {@link SeasonalItemGroup} appears */ public @Nonnull Month getMonth() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java index 35b5aef3d1..069bd639e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/SubItemGroup.java @@ -1,17 +1,15 @@ package io.github.thebusybiscuit.slimefun4.api.items.groups; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * The {@link SubItemGroup} is a child {@link ItemGroup} of the * {@link NestedItemGroup}. @@ -94,5 +92,4 @@ public final void register(@Nonnull SlimefunAddon addon) { parentItemGroup.register(addon); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java index e95ee138f5..45620e4cab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/groups/package-info.java @@ -1,4 +1,4 @@ /** * This package contains a few {@link io.github.thebusybiscuit.slimefun4.api.items.ItemGroup} variations. */ -package io.github.thebusybiscuit.slimefun4.api.items.groups; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.items.groups; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java index fd1bd1c8d6..6e4a0a2d3a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/package-info.java @@ -3,4 +3,4 @@ * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem}, such as * {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting} */ -package io.github.thebusybiscuit.slimefun4.api.items; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.items; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java index 3caeb974b3..7fac2e6eb5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/DoubleRangeSetting.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This variation of {@link ItemSetting} allows you to define an {@link Double} range * and enforces this range using the {@link #validateInput(Double)} method. - * + * * @author TheBusyBiscuit - * + * * @see ItemSetting * @see IntRangeSetting * @@ -45,7 +43,7 @@ public boolean validateInput(Double input) { /** * This returns the minimum value of this {@link DoubleRangeSetting}. - * + * * @return The minimum value */ public final double getMinimum() { @@ -54,11 +52,10 @@ public final double getMinimum() { /** * This returns the maximum value of this {@link DoubleRangeSetting}. - * + * * @return The maximum value */ public final double getMaximum() { return max; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java index 0b2405ec22..7327799184 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/EnumSetting.java @@ -1,14 +1,12 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.Arrays; import java.util.stream.Collectors; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be * used for {@link ItemSetting} validation. @@ -74,5 +72,4 @@ public boolean validateInput(String input) { return false; } } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java index 58e5dc34bf..ea119c1aaa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/IntRangeSetting.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This variation of {@link ItemSetting} allows you to define an {@link Integer} range * and enforces this range using the {@link #validateInput(Integer)} method. - * + * * @author TheBusyBiscuit - * + * * @see ItemSetting * @see DoubleRangeSetting * @@ -45,7 +43,7 @@ public boolean validateInput(Integer input) { /** * This returns the minimum value of this {@link IntRangeSetting}. - * + * * @return The minimum value */ public final int getMinimum() { @@ -54,11 +52,10 @@ public final int getMinimum() { /** * This returns the maximum value of this {@link IntRangeSetting}. - * + * * @return The maximum value */ public final int getMaximum() { return max; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java index 047f08d4d5..60fceecba3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/MaterialTagSetting.java @@ -1,26 +1,23 @@ package io.github.thebusybiscuit.slimefun4.api.items.settings; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.List; import java.util.stream.Collectors; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.Material; import org.bukkit.Tag; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This variation of {@link ItemSetting} allows you to define a default {@link Tag}. * The {@link Tag} will be translated into a {@link String} {@link List} which the user * can then configure as they wish. - * + * * It also validates all inputs to be a valid {@link Material}. - * + * * @author TheBusyBiscuit - * + * * @see ItemSetting * */ @@ -37,7 +34,7 @@ public MaterialTagSetting(SlimefunItem item, String key, Tag defaultTa /** * This {@link Tag} holds the default values for this {@link MaterialTagSetting}. - * + * * @return The default {@link Tag} */ public @Nonnull Tag getDefaultTag() { @@ -69,14 +66,13 @@ public boolean validateInput(List input) { /** * Internal method to turn a {@link Tag} into a {@link List} of {@link String Strings}. - * + * * @param tag * Our {@link Tag} - * + * * @return The {@link String} {@link List} */ private static @Nonnull List getAsStringList(@Nonnull Tag tag) { return tag.getValues().stream().map(Material::name).collect(Collectors.toList()); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java index 0a12d616c3..4881393d75 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/settings/package-info.java @@ -1,4 +1,4 @@ /** * This package contains various sub classes of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemSetting}. */ -package io.github.thebusybiscuit.slimefun4.api.items.settings; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.items.settings; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java index 0007edd745..a787c2d628 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java @@ -82,8 +82,7 @@ protected Network(@Nonnull NetworkManager manager, @Nonnull Location regulator) * * @return The assigned type of {@link NetworkComponent} for this {@link Location} */ - @Nullable - public abstract NetworkComponent classifyLocation(@Nonnull Location l); + @Nullable public abstract NetworkComponent classifyLocation(@Nonnull Location l); /** * This method is called whenever a {@link Location} in this {@link Network} changes @@ -153,8 +152,7 @@ public boolean connectsTo(@Nonnull Location l) { } } - @Nullable - private NetworkComponent getCurrentClassification(@Nonnull Location l) { + @Nullable private NetworkComponent getCurrentClassification(@Nonnull Location l) { if (regulatorNodes.contains(l)) { return NetworkComponent.REGULATOR; } else if (connectorNodes.contains(l)) { @@ -176,7 +174,8 @@ private void discoverStep() { NetworkComponent classification = classifyLocation(l); if (classification != currentAssignment) { - if (currentAssignment == NetworkComponent.REGULATOR || currentAssignment == NetworkComponent.CONNECTOR) { + if (currentAssignment == NetworkComponent.REGULATOR + || currentAssignment == NetworkComponent.CONNECTOR) { // Requires a complete rebuild of the network, so we just throw the current one away. manager.unregisterNetwork(this); return; @@ -248,4 +247,4 @@ public Location getRegulator() { public void tick() { discoverStep(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java index 1155171673..b5059f8bad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkComponent.java @@ -11,7 +11,7 @@ * @see NetworkManager */ public enum NetworkComponent { - - CONNECTOR, REGULATOR, TERMINUS - -} \ No newline at end of file + CONNECTOR, + REGULATOR, + TERMINUS +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java index 058a459779..71abce5594 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/NetworkVisualizer.java @@ -1,12 +1,11 @@ package io.github.thebusybiscuit.slimefun4.api.network; +import javax.annotation.Nonnull; import org.bukkit.Color; import org.bukkit.Location; import org.bukkit.Particle; import org.bukkit.Particle.DustOptions; -import javax.annotation.Nonnull; - /** * This class represents the visualizer task of a given {@link Network}. * @@ -50,7 +49,8 @@ public void run() { * @param l The {@link Location} of our node */ private void spawnParticles(@Nonnull Location l) { - l.getWorld().spawnParticle(Particle.REDSTONE, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, options); + l.getWorld() + .spawnParticle( + Particle.REDSTONE, l.getX() + 0.5, l.getY() + 0.5, l.getZ() + 0.5, 1, 0, 0, 0, 1, options); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java index b2232cf176..41b286cb34 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/package-info.java @@ -1,4 +1,4 @@ /** * This package provides the API infrastructure for networks, such as the Cargo- or Energy net. */ -package io.github.thebusybiscuit.slimefun4.api.network; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.network; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java index 7929e334cc..6c6be23d5c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/package-info.java @@ -2,4 +2,4 @@ * This package contains a bunch of classes and sub-packages related to the interaction * with Slimefun via an API. */ -package io.github.thebusybiscuit.slimefun4.api; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java index 8fd52f558a..dba61470d2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerBackpack.java @@ -27,10 +27,10 @@ /** * This class represents the instance of a {@link SlimefunBackpack} that is ready to * be opened. - * + * * It holds an actual {@link Inventory} and represents the backpack on the * level of an individual {@link ItemStack} as opposed to the class {@link SlimefunBackpack}. - * + * * @author TheBusyBiscuit * * @see SlimefunBackpack @@ -55,9 +55,9 @@ public static void getAsync(ItemStack item, Consumer callback, b var bUuid = getBackpackUUID(item.getItemMeta()); if (bUuid.isPresent()) { - Slimefun.getDatabaseManager().getProfileDataController().getBackpackAsync( - bUuid.get(), - new IAsyncReadCallback<>() { + Slimefun.getDatabaseManager() + .getProfileDataController() + .getBackpackAsync(bUuid.get(), new IAsyncReadCallback<>() { @Override public boolean runOnMainThread() { return runCbOnMainThread; @@ -67,8 +67,7 @@ public boolean runOnMainThread() { public void onResult(PlayerBackpack result) { callback.accept(result); } - } - ); + }); return; } @@ -90,25 +89,25 @@ public void onResult(PlayerBackpack result) { if (id.isPresent()) { int number = id.getAsInt(); - Slimefun.getDatabaseManager().getProfileDataController().getBackpackAsync( - Bukkit.getOfflinePlayer(UUID.fromString(uuid)), - number, - new IAsyncReadCallback<>() { - @Override - public boolean runOnMainThread() { - return runCbOnMainThread; - } - - @Override - public void onResult(PlayerBackpack result) { - var meta = item.getItemMeta(); - meta.getPersistentDataContainer().set(KEY_BACKPACK_UUID, PersistentDataType.STRING, result.uuid.toString()); - item.setItemMeta(meta); - // TODO: upgrade lore - callback.accept(result); - } - } - ); + Slimefun.getDatabaseManager() + .getProfileDataController() + .getBackpackAsync( + Bukkit.getOfflinePlayer(UUID.fromString(uuid)), number, new IAsyncReadCallback<>() { + @Override + public boolean runOnMainThread() { + return runCbOnMainThread; + } + + @Override + public void onResult(PlayerBackpack result) { + var meta = item.getItemMeta(); + meta.getPersistentDataContainer() + .set(KEY_BACKPACK_UUID, PersistentDataType.STRING, result.uuid.toString()); + item.setItemMeta(meta); + // TODO: upgrade lore + callback.accept(result); + } + }); } } @@ -134,7 +133,8 @@ public static OptionalInt getBackpackID(ItemMeta meta) { for (String line : meta.getLore()) { if (line.startsWith(ChatColors.color("&7ID: ")) && line.contains("#")) { try { - return OptionalInt.of(Integer.parseInt(CommonPatterns.HASH.split(line.replace(ChatColors.color("&7ID: "), ""))[1])); + return OptionalInt.of(Integer.parseInt( + CommonPatterns.HASH.split(line.replace(ChatColors.color("&7ID: "), ""))[1])); } catch (NumberFormatException e) { e.printStackTrace(); } @@ -195,7 +195,8 @@ private static void setItem(ItemMeta meta, PlayerBackpack bp) { } @ParametersAreNonnullByDefault - public PlayerBackpack(OfflinePlayer owner, UUID uuid, String name, int id, int size, @Nullable ItemStack[] contents) { + public PlayerBackpack( + OfflinePlayer owner, UUID uuid, String name, int id, int size, @Nullable ItemStack[] contents) { if (size < 9 || size > 54 || size % 9 != 0) { throw new IllegalArgumentException("Invalid size! Size must be one of: [9, 18, 27, 36, 45, 54]"); } @@ -219,7 +220,7 @@ public PlayerBackpack(OfflinePlayer owner, UUID uuid, String name, int id, int s /** * This returns the id of this {@link PlayerBackpack} - * + * * @return The id of this {@link PlayerBackpack} */ public int getId() { @@ -228,7 +229,7 @@ public int getId() { /** * This method returns the {@link PlayerProfile} this {@link PlayerBackpack} belongs to - * + * * @return The owning {@link PlayerProfile} */ @Nonnull @@ -238,7 +239,7 @@ public OfflinePlayer getOwner() { /** * This returns the size of this {@link PlayerBackpack}. - * + * * @return The size of this {@link PlayerBackpack} */ public int getSize() { @@ -272,7 +273,7 @@ public void open(Player p) { /** * This will change the current size of this Backpack to the specified size. - * + * * @param size * The new size for this Backpack */ @@ -317,7 +318,8 @@ public boolean isInvalid() { * @return new {@link Inventory} */ private Inventory newInv() { - return Bukkit.createInventory(this, size, (name.isEmpty() ? "背包" : ChatColors.color(name + "&r")) + " [大小 " + size + "]"); + return Bukkit.createInventory( + this, size, (name.isEmpty() ? "背包" : ChatColors.color(name + "&r")) + " [大小 " + size + "]"); } private void updateInv() { @@ -328,5 +330,4 @@ private void updateInv() { this.inventory = inv; setInventory(inv); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java index 6f923c18bb..dad0f317fa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java @@ -39,9 +39,9 @@ /** * A class that can store a Player's {@link Research} progress for caching purposes. * It also holds the backpacks of a {@link Player}. - * + * * @author TheBusyBiscuit - * + * * @see Research * @see Waypoint * @see HashedArmorpiece @@ -61,7 +61,9 @@ public class PlayerProfile { private final List waypoints = new ArrayList<>(); private final GuideHistory guideHistory = new GuideHistory(this); - private final HashedArmorpiece[] armor = { new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece() }; + private final HashedArmorpiece[] armor = { + new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece(), new HashedArmorpiece() + }; public PlayerProfile(@Nonnull OfflinePlayer p, int backpackNum) { this(p, backpackNum, new HashSet<>()); @@ -79,13 +81,18 @@ public PlayerProfile(@Nonnull OfflinePlayer p, int backpackNum, Set re private void loadWaypoint() { for (String key : waypointsFile.getKeys()) { try { - if (waypointsFile.contains(key + ".world") && Bukkit.getWorld(waypointsFile.getString(key + ".world")) != null) { + if (waypointsFile.contains(key + ".world") + && Bukkit.getWorld(waypointsFile.getString(key + ".world")) != null) { String waypointName = waypointsFile.getString(key + ".name"); Location loc = waypointsFile.getLocation(key); waypoints.add(new Waypoint(this, key, loc, waypointName)); } } catch (Exception x) { - Slimefun.logger().log(Level.WARNING, x, () -> "Could not load Waypoint \"" + key + "\" for Player \"" + owner.getName() + '"'); + Slimefun.logger() + .log( + Level.WARNING, + x, + () -> "Could not load Waypoint \"" + key + "\" for Player \"" + owner.getName() + '"'); } } } @@ -93,7 +100,7 @@ private void loadWaypoint() { /** * This method provides a fast way to access the armor of a {@link Player}. * It returns a cached version, represented by {@link HashedArmorpiece}. - * + * * @return The cached armor for this {@link Player} */ public @Nonnull HashedArmorpiece[] getArmor() { @@ -102,7 +109,7 @@ private void loadWaypoint() { /** * This returns the {@link UUID} this {@link PlayerProfile} is linked to. - * + * * @return The {@link UUID} of our {@link PlayerProfile} */ public @Nonnull UUID getUUID() { @@ -112,7 +119,7 @@ private void loadWaypoint() { /** * This method returns whether the {@link Player} has logged off. * If this is true, then the Profile can be removed from RAM. - * + * * @return Whether the Profile is marked for deletion */ public boolean isMarkedForDeletion() { @@ -121,7 +128,7 @@ public boolean isMarkedForDeletion() { /** * This method returns whether the Profile has unsaved changes - * + * * @return Whether there are unsaved changes */ public boolean isDirty() { @@ -140,7 +147,7 @@ public void save() { /** * This method sets the Player's "researched" status for this Research. * Use the boolean to unlock or lock the {@link Research} - * + * * @param research * The {@link Research} that should be unlocked or locked * @param unlock @@ -155,15 +162,17 @@ public void setResearched(@Nonnull Research research, boolean unlock) { } else { researches.remove(research); } - Slimefun.getDatabaseManager().getProfileDataController().setResearch(owner.getUniqueId().toString(), research.getKey(), unlock); + Slimefun.getDatabaseManager() + .getProfileDataController() + .setResearch(owner.getUniqueId().toString(), research.getKey(), unlock); } /** * This method returns whether the {@link Player} has unlocked the given {@link Research} - * + * * @param research * The {@link Research} that is being queried - * + * * @return Whether this {@link Research} has been unlocked */ public boolean hasUnlocked(@Nullable Research research) { @@ -177,7 +186,7 @@ public boolean hasUnlocked(@Nullable Research research) { /** * This method returns whether this {@link Player} has unlocked all {@link Research Researches}. - * + * * @return Whether they unlocked every {@link Research} */ public boolean hasUnlockedEverything() { @@ -194,7 +203,7 @@ public boolean hasUnlockedEverything() { /** * This Method will return all Researches that this {@link Player} has unlocked - * + * * @return A {@code Hashset} of all Researches this {@link Player} has unlocked */ public @Nonnull Set getResearches() { @@ -204,7 +213,7 @@ public boolean hasUnlockedEverything() { /** * This returns a {@link List} of all {@link Waypoint Waypoints} belonging to this * {@link PlayerProfile}. - * + * * @return A {@link List} containing every {@link Waypoint} */ public @Nonnull List getWaypoints() { @@ -214,7 +223,7 @@ public boolean hasUnlockedEverything() { /** * This adds the given {@link Waypoint} to the {@link List} of {@link Waypoint Waypoints} * of this {@link PlayerProfile}. - * + * * @param waypoint * The {@link Waypoint} to add */ @@ -239,7 +248,7 @@ public void addWaypoint(@Nonnull Waypoint waypoint) { /** * This removes the given {@link Waypoint} from the {@link List} of {@link Waypoint Waypoints} * of this {@link PlayerProfile}. - * + * * @param waypoint * The {@link Waypoint} to remove */ @@ -285,7 +294,8 @@ public void setBackpackCount(int count) { public @Nonnull String getTitle() { List titles = Slimefun.getRegistry().getResearchRanks(); - float fraction = (float) researches.size() / Slimefun.getRegistry().getResearches().size(); + float fraction = (float) researches.size() + / Slimefun.getRegistry().getResearches().size(); int index = (int) (fraction * (titles.size() - 1)); return titles.get(index); @@ -293,7 +303,8 @@ public void setBackpackCount(int count) { public void sendStats(@Nonnull CommandSender sender) { Set unlockedResearches = getResearches(); - int levels = unlockedResearches.stream().mapToInt(Research::getLevelCost).sum(); + int levels = + unlockedResearches.stream().mapToInt(Research::getLevelCost).sum(); int allResearches = nonEmptyResearches(); float progress = Math.round(((unlockedResearches.size() * 100.0F) / allResearches) * 100.0F) / 100.0F; @@ -302,14 +313,23 @@ public void sendStats(@Nonnull CommandSender sender) { sender.sendMessage(ChatColors.color("&7玩家研究统计: &b" + owner.getName())); sender.sendMessage(""); sender.sendMessage(ChatColors.color("&7研究等级: " + ChatColor.AQUA + getTitle())); - sender.sendMessage(ChatColors.color("&7研究进度: " + NumberUtils.getColorFromPercentage(progress) + progress + " &r% " + ChatColor.YELLOW + '(' + unlockedResearches.size() + " / " + allResearches + ')')); + sender.sendMessage(ChatColors.color("&7研究进度: " + + NumberUtils.getColorFromPercentage(progress) + + progress + + " &r% " + + ChatColor.YELLOW + + '(' + + unlockedResearches.size() + + " / " + + allResearches + + ')')); sender.sendMessage(ChatColors.color("&7总花费经验等级: " + ChatColor.AQUA + levels)); } /** * This returns the {@link Player} who this {@link PlayerProfile} belongs to. * If the {@link Player} is offline, null will be returned. - * + * * @return The {@link Player} of this {@link PlayerProfile} or null */ public @Nullable Player getPlayer() { @@ -319,7 +339,7 @@ public void sendStats(@Nonnull CommandSender sender) { /** * This returns the {@link GuideHistory} of this {@link Player}. * It is basically that player's browsing history. - * + * * @return The {@link GuideHistory} of this {@link Player} */ public @Nonnull GuideHistory getGuideHistory() { @@ -337,7 +357,7 @@ public static boolean fromUUID(@Nonnull UUID uuid, @Nonnull Consumer callback) { @@ -358,10 +378,10 @@ public static boolean get(@Nonnull OfflinePlayer p, @Nonnull Consumer find(@Nonnull OfflinePlayer p) { @@ -453,9 +473,9 @@ public boolean isInvalid() { // returns the amount of researches with at least 1 enabled item private int nonEmptyResearches() { - return (int) Slimefun.getRegistry().getResearches() - .stream() - .filter(research -> research.getAffectedItems().stream().anyMatch(item -> item.getState() == ItemState.ENABLED)) + return (int) Slimefun.getRegistry().getResearches().stream() + .filter(research -> + research.getAffectedItems().stream().anyMatch(item -> item.getState() == ItemState.ENABLED)) .count(); } @@ -483,5 +503,4 @@ private void invokeCb(PlayerProfile pf) { } }); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java index a66daf5fbf..23d2453a09 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java @@ -1,27 +1,24 @@ package io.github.thebusybiscuit.slimefun4.api.player; +import io.github.bakedlibs.dough.common.CommonPatterns; +import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import java.util.Optional; import java.util.OptionalInt; import java.util.concurrent.TimeUnit; - import javax.annotation.Nonnull; - import org.bukkit.Keyed; import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; -import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; - /** * A very simple API that is meant for adding/getting/clearing custom status effects * to/from players. - * + * * The effects are stored via {@link PersistentDataAPI} and use NBT data that is * saved across server restarts. - * + * * You can specify a level for your status effect too. - * + * * @author TheBusyBiscuit * */ @@ -42,7 +39,7 @@ public StatusEffect(@Nonnull NamespacedKey key) { * This applies this {@link StatusEffect} to the given {@link Player}. * You can specify a duration, this will reference * {@link StatusEffect#add(Player, int, int, TimeUnit)} with a level of 1. - * + * * @param p * The {@link Player} whom to apply the effect to * @param duration @@ -56,7 +53,7 @@ public void add(@Nonnull Player p, int duration, @Nonnull TimeUnit unit) { /** * This applies this {@link StatusEffect} to the given {@link Player}. - * + * * @param p * The {@link Player} whom to apply the effect to * @param level @@ -73,7 +70,7 @@ public void add(@Nonnull Player p, int level, int duration, @Nonnull TimeUnit un /** * This applies this {@link StatusEffect} to the given {@link Player}. * This will apply it permanently, there is no duration. - * + * * @param p * The {@link Player} whom to apply the effect to * @param level @@ -88,7 +85,7 @@ public void addPermanent(@Nonnull Player p, int level) { * to that {@link Player}. * If the effect has expired, it will automatically remove all associated * NBT data of this effect. - * + * * @param p * The {@link Player} to check for * @return Whether this {@link StatusEffect} is currently applied @@ -114,7 +111,7 @@ public boolean isPresent(@Nonnull Player p) { /** * This method returns an {@link OptionalInt} describing the level of this status * effect on that player. - * + * * @param p * The {@link Player} to check for * @return An {@link OptionalInt} that describes the result @@ -132,12 +129,11 @@ public boolean isPresent(@Nonnull Player p) { /** * This will remove this {@link StatusEffect} from the given {@link Player}. - * + * * @param p * The {@link Player} to clear it from */ public void clear(@Nonnull Player p) { PersistentDataAPI.remove(p, getKey()); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java index b213a63aab..30773f7d1e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/package-info.java @@ -2,4 +2,4 @@ * This package stores API-related classes that are related to a {@link org.bukkit.entity.Player}, * such as the {@link io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile} for example. */ -package io.github.thebusybiscuit.slimefun4.api.player; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.player; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java index 6a569c9077..18b43f5040 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/RecipeType.java @@ -31,41 +31,108 @@ // TODO: Remove this class and rewrite the recipe system public class RecipeType implements Keyed { - public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), new CustomItemStack(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); - public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(Slimefun.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge"); - public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(Slimefun.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone"); - public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery"); - public static final RecipeType ORE_CRUSHER = new RecipeType(new NamespacedKey(Slimefun.instance(), "ore_crusher"), SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher"); - public static final RecipeType GOLD_PAN = new RecipeType(new NamespacedKey(Slimefun.instance(), "gold_pan"), SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item"); - public static final RecipeType COMPRESSOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "compressor"), SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor"); - public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "pressure_chamber"), SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber"); - public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new NamespacedKey(Slimefun.instance(), "magic_workbench"), SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench"); - public static final RecipeType ORE_WASHER = new RecipeType(new NamespacedKey(Slimefun.instance(), "ore_washer"), SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer"); - public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(Slimefun.instance(), "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power..."); - public static final RecipeType JUICER = new RecipeType(new NamespacedKey(Slimefun.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation"); - - public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(Slimefun.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR, (recipe, output) -> { - AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output); - AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem()); - altar.getRecipes().add(altarRecipe); - }, (recipe, output) -> { - AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output); - AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem()); - altar.getRecipes().removeIf(ar -> ar.equals(altarRecipe)); - }); - - public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "mob_drop"), new CustomItemStack(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item"); - public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "barter_drop"), new CustomItemStack(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item"); - public static final RecipeType INTERACT = new RecipeType(new NamespacedKey(Slimefun.instance(), "interact"), new CustomItemStack(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item")); - - public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER); - public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR); - public static final RecipeType FOOD_COMPOSTER = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER); - public static final RecipeType FREEZER = new RecipeType(new NamespacedKey(Slimefun.instance(), "freezer"), SlimefunItems.FREEZER); - public static final RecipeType REFINERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "refinery"), SlimefunItems.REFINERY); - - public static final RecipeType GEO_MINER = new RecipeType(new NamespacedKey(Slimefun.instance(), "geo_miner"), SlimefunItems.GEO_MINER); - public static final RecipeType NUCLEAR_REACTOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR); + public static final RecipeType MULTIBLOCK = new RecipeType( + new NamespacedKey(Slimefun.instance(), "multiblock"), + new CustomItemStack(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World")); + public static final RecipeType ARMOR_FORGE = new RecipeType( + new NamespacedKey(Slimefun.instance(), "armor_forge"), + SlimefunItems.ARMOR_FORGE, + "", + "&a&oCraft it in an Armor Forge"); + public static final RecipeType GRIND_STONE = new RecipeType( + new NamespacedKey(Slimefun.instance(), "grind_stone"), + SlimefunItems.GRIND_STONE, + "", + "&a&oGrind it using the Grind Stone"); + public static final RecipeType SMELTERY = new RecipeType( + new NamespacedKey(Slimefun.instance(), "smeltery"), + SlimefunItems.SMELTERY, + "", + "&a&oSmelt it using a Smeltery"); + public static final RecipeType ORE_CRUSHER = new RecipeType( + new NamespacedKey(Slimefun.instance(), "ore_crusher"), + SlimefunItems.ORE_CRUSHER, + "", + "&a&oCrush it using the Ore Crusher"); + public static final RecipeType GOLD_PAN = new RecipeType( + new NamespacedKey(Slimefun.instance(), "gold_pan"), + SlimefunItems.GOLD_PAN, + "", + "&a&oUse a Gold Pan on Gravel to obtain this Item"); + public static final RecipeType COMPRESSOR = new RecipeType( + new NamespacedKey(Slimefun.instance(), "compressor"), + SlimefunItems.COMPRESSOR, + "", + "&a&oCompress it using the Compressor"); + public static final RecipeType PRESSURE_CHAMBER = new RecipeType( + new NamespacedKey(Slimefun.instance(), "pressure_chamber"), + SlimefunItems.PRESSURE_CHAMBER, + "", + "&a&oCompress it using the Pressure Chamber"); + public static final RecipeType MAGIC_WORKBENCH = new RecipeType( + new NamespacedKey(Slimefun.instance(), "magic_workbench"), + SlimefunItems.MAGIC_WORKBENCH, + "", + "&a&oCraft it in a Magic Workbench"); + public static final RecipeType ORE_WASHER = new RecipeType( + new NamespacedKey(Slimefun.instance(), "ore_washer"), + SlimefunItems.ORE_WASHER, + "", + "&a&oWash it in an Ore Washer"); + public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType( + new NamespacedKey(Slimefun.instance(), "enhanced_crafting_table"), + SlimefunItems.ENHANCED_CRAFTING_TABLE, + "", + "&a&oA regular Crafting Table cannot", + "&a&ohold this massive Amount of Power..."); + public static final RecipeType JUICER = new RecipeType( + new NamespacedKey(Slimefun.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation"); + + public static final RecipeType ANCIENT_ALTAR = new RecipeType( + new NamespacedKey(Slimefun.instance(), "ancient_altar"), + SlimefunItems.ANCIENT_ALTAR, + (recipe, output) -> { + AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output); + AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem()); + altar.getRecipes().add(altarRecipe); + }, + (recipe, output) -> { + AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output); + AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem()); + altar.getRecipes().removeIf(ar -> ar.equals(altarRecipe)); + }); + + public static final RecipeType MOB_DROP = new RecipeType( + new NamespacedKey(Slimefun.instance(), "mob_drop"), + new CustomItemStack(Material.IRON_SWORD, "&bMob Drop"), + RecipeType::registerMobDrop, + "", + "&rKill the specified Mob to obtain this Item"); + public static final RecipeType BARTER_DROP = new RecipeType( + new NamespacedKey(Slimefun.instance(), "barter_drop"), + new CustomItemStack(Material.GOLD_INGOT, "&bBarter Drop"), + RecipeType::registerBarterDrop, + "&aBarter with piglins for a chance", + "&ato obtain this item"); + public static final RecipeType INTERACT = new RecipeType( + new NamespacedKey(Slimefun.instance(), "interact"), + new CustomItemStack(Material.PLAYER_HEAD, "&bInteract", "", "&a&oRight click with this item")); + + public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType( + new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER); + public static final RecipeType FOOD_FABRICATOR = + new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR); + public static final RecipeType FOOD_COMPOSTER = + new RecipeType(new NamespacedKey(Slimefun.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER); + public static final RecipeType FREEZER = + new RecipeType(new NamespacedKey(Slimefun.instance(), "freezer"), SlimefunItems.FREEZER); + public static final RecipeType REFINERY = + new RecipeType(new NamespacedKey(Slimefun.instance(), "refinery"), SlimefunItems.REFINERY); + + public static final RecipeType GEO_MINER = + new RecipeType(new NamespacedKey(Slimefun.instance(), "geo_miner"), SlimefunItems.GEO_MINER); + public static final RecipeType NUCLEAR_REACTOR = + new RecipeType(new NamespacedKey(Slimefun.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR); public static final RecipeType NULL = new RecipeType(); @@ -108,7 +175,12 @@ public RecipeType(NamespacedKey key, ItemStack item, BiConsumer registerCallback, BiConsumer unregisterCallback, String... lore) { + public RecipeType( + NamespacedKey key, + ItemStack item, + BiConsumer registerCallback, + BiConsumer unregisterCallback, + String... lore) { this.item = new CustomItemStack(item, null, lore); this.key = key; this.registerConsumer = registerCallback; @@ -130,7 +202,8 @@ public RecipeType(NamespacedKey key, ItemStack item) { public RecipeType(MinecraftRecipe recipe) { this.item = new ItemStack(recipe.getMachine()); this.machine = ""; - this.key = NamespacedKey.minecraft(recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", "")); + this.key = NamespacedKey.minecraft( + recipe.getRecipeClass().getSimpleName().toLowerCase(Locale.ROOT).replace("recipe", "")); } public void register(ItemStack[] recipe, ItemStack result) { @@ -195,7 +268,9 @@ private static void registerBarterDrop(ItemStack[] recipe, ItemStack output) { @ParametersAreNonnullByDefault private static void registerMobDrop(ItemStack[] recipe, ItemStack output) { - String mob = ChatColor.stripColor(recipe[4].getItemMeta().getDisplayName()).toUpperCase(Locale.ROOT).replace(' ', '_'); + String mob = ChatColor.stripColor(recipe[4].getItemMeta().getDisplayName()) + .toUpperCase(Locale.ROOT) + .replace(' ', '_'); EntityType entity = EntityType.valueOf(mob); Set dropping = Slimefun.getRegistry().getMobDrops().getOrDefault(entity, new HashSet<>()); dropping.add(output); @@ -257,4 +332,4 @@ public static ItemStack getRecipeOutputList(MultiBlockMachine machine, ItemStack List recipes = machine.getRecipes(); return recipes.get((recipes.indexOf(input) + 1))[0]; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java index ac5c2a8d45..d756a20368 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/recipes/package-info.java @@ -1,4 +1,4 @@ /** * This package contains all classes related to our recipe system. */ -package io.github.thebusybiscuit.slimefun4.api.recipes; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.recipes; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java index 70403ead2c..7a77dd1d4e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/PlayerResearchTask.java @@ -1,27 +1,23 @@ package io.github.thebusybiscuit.slimefun4.api.researches; -import java.util.function.Consumer; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; - -import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings; import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils; - +import java.util.function.Consumer; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.commons.lang.Validate; +import org.bukkit.Bukkit; +import org.bukkit.entity.Player; /** * A {@link PlayerResearchTask} is run when a {@link Player} unlocks a {@link Research}. * * @author TheBusyBiscuit - * + * * @see Research * @see ResearchUnlockEvent * @see PlayerProfile @@ -64,10 +60,15 @@ public void accept(PlayerProfile profile) { } if (!isInstant) { - Slimefun.runSync(() -> { - SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p); - Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", "0%")); - }, 5L); + Slimefun.runSync( + () -> { + SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p); + Slimefun.getLocalization() + .sendMessage(p, "messages.research.progress", true, msg -> msg.replace( + PLACEHOLDER, research.getName(p)) + .replace("%progress%", "0%")); + }, + 5L); } ResearchUnlockEvent event = new ResearchUnlockEvent(p, research); @@ -76,14 +77,25 @@ public void accept(PlayerProfile profile) { if (!event.isCancelled()) { if (isInstant) { Slimefun.runSync(() -> unlockResearch(p, profile)); - } else if (Slimefun.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) { - Slimefun.getLocalization().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER, research.getName(p))); + } else if (Slimefun.getRegistry() + .getCurrentlyResearchingPlayers() + .add(p.getUniqueId())) { + Slimefun.getLocalization() + .sendMessage( + p, + "messages.research.start", + true, + msg -> msg.replace(PLACEHOLDER, research.getName(p))); sendUpdateMessage(p); - Slimefun.runSync(() -> { - unlockResearch(p, profile); - Slimefun.getRegistry().getCurrentlyResearchingPlayers().remove(p.getUniqueId()); - }, (RESEARCH_PROGRESS.length + 1) * 20L); + Slimefun.runSync( + () -> { + unlockResearch(p, profile); + Slimefun.getRegistry() + .getCurrentlyResearchingPlayers() + .remove(p.getUniqueId()); + }, + (RESEARCH_PROGRESS.length + 1) * 20L); } } } @@ -93,20 +105,23 @@ private void sendUpdateMessage(@Nonnull Player p) { for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) { int index = i; - Slimefun.runSync(() -> { - SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p); + Slimefun.runSync( + () -> { + SoundEffect.PLAYER_RESEARCHING_SOUND.playFor(p); - Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> { - String progress = RESEARCH_PROGRESS[index - 1] + "%"; - return msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", progress); - }); - }, i * 20L); + Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> { + String progress = RESEARCH_PROGRESS[index - 1] + "%"; + return msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", progress); + }); + }, + i * 20L); } } private void unlockResearch(@Nonnull Player p, @Nonnull PlayerProfile profile) { profile.setResearched(research, true); - Slimefun.getLocalization().sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER, research.getName(p))); + Slimefun.getLocalization() + .sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER, research.getName(p))); onFinish(p); // Check if the Server and the Player have enabled fireworks for researches @@ -117,7 +132,7 @@ private void unlockResearch(@Nonnull Player p, @Nonnull PlayerProfile profile) { /** * This method is called when the {@link Research} successfully finished to unlock. - * + * * @param p * The {@link Player} who has unlocked this {@link Research} */ @@ -126,4 +141,4 @@ private void onFinish(@Nonnull Player p) { callback.accept(p); } } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java index f2c1bd33d2..517dcfee2b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/Research.java @@ -65,7 +65,8 @@ public class Research implements Keyed { * The Cost in economy to unlock this {@link Research} * */ - public Research(@Nonnull NamespacedKey key, int id, @Nonnull String defaultName, int levelCost, double currencyCost) { + public Research( + @Nonnull NamespacedKey key, int id, @Nonnull String defaultName, int levelCost, double currencyCost) { Validate.notNull(key, "A NamespacedKey must be provided"); Validate.notNull(defaultName, "A default name must be specified"); @@ -114,7 +115,7 @@ public Research(@Nonnull NamespacedKey key, int id, @Nonnull String defaultName, * This method returns whether this {@link Research} is enabled. * {@code false} can mean that this particular {@link Research} was disabled or that * researches altogether have been disabled. - * + * * @return Whether this {@link Research} is enabled or not */ public boolean isEnabled() { @@ -124,9 +125,9 @@ public boolean isEnabled() { /** * Gets the ID of this {@link Research}. * This is the old way of identifying Researches, use a {@link NamespacedKey} in the future. - * + * * @deprecated Numeric Ids for Researches are deprecated, use {@link #getKey()} for identification instead. - * + * * @return The ID of this {@link Research} */ @Deprecated @@ -138,10 +139,10 @@ public int getID() { * This method gives you a localized name for this {@link Research}. * The name is automatically taken from the currently selected {@link Language} of * the specified {@link Player}. - * + * * @param p * The {@link Player} to translate this name for. - * + * * @return The localized Name of this {@link Research}. */ public @Nonnull String getName(@Nonnull Player p) { @@ -208,7 +209,7 @@ public void setLevelCost(int levelCost) { /** * Bind the specified {@link SlimefunItem SlimefunItems} to this {@link Research}. - * + * * @param items * Instances of {@link SlimefunItem} to bind to this {@link Research} */ @@ -222,10 +223,10 @@ public void addItems(SlimefunItem... items) { /** * Bind the specified ItemStacks to this {@link Research}. - * + * * @param items * Instances of {@link ItemStack} to bind to this {@link Research} - * + * * @return The current instance of {@link Research} */ @Nonnull @@ -243,7 +244,7 @@ public Research addItems(ItemStack... items) { /** * Lists every {@link SlimefunItem} that is bound to this {@link Research}. - * + * * @return The Slimefun items bound to this {@link Research}. */ @Nonnull @@ -270,7 +271,13 @@ public List getAffectedItems() { * */ @ParametersAreNonnullByDefault - public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup itemGroup, int page) { + public void unlockFromGuide( + SlimefunGuideImplementation guide, + Player player, + PlayerProfile profile, + SlimefunItem sfItem, + ItemGroup itemGroup, + int page) { if (!Slimefun.getRegistry().getCurrentlyResearchingPlayers().contains(player.getUniqueId())) { if (profile.hasUnlocked(this)) { guide.openItemGroup(profile, itemGroup, page); @@ -310,14 +317,15 @@ public boolean canUnlock(@Nonnull Player p) { canUnlock = p.getLevel() >= levelCost; } - boolean creativeResearch = p.getGameMode() == GameMode.CREATIVE && Slimefun.getConfigManager().isFreeCreativeResearchingEnabled(); + boolean creativeResearch = p.getGameMode() == GameMode.CREATIVE + && Slimefun.getConfigManager().isFreeCreativeResearchingEnabled(); return creativeResearch || canUnlock; } /** * This unlocks this {@link Research} for the given {@link Player} without any form of callback. - * + * * @param p * The {@link Player} who should unlock this {@link Research} * @param instant @@ -329,7 +337,7 @@ public void unlock(@Nonnull Player p, boolean instant) { /** * Unlocks this {@link Research} for the specified {@link Player}. - * + * * @param p * The {@link Player} for which to unlock this {@link Research} * @param isInstant @@ -348,7 +356,8 @@ public void register() { Slimefun.getResearchCfg().setDefaultValue("enable-researching", true); String path = key.getNamespace() + '.' + key.getKey(); - if (Slimefun.getResearchCfg().contains(path + ".enabled") && !Slimefun.getResearchCfg().getBoolean(path + ".enabled")) { + if (Slimefun.getResearchCfg().contains(path + ".enabled") + && !Slimefun.getResearchCfg().getBoolean(path + ".enabled")) { for (SlimefunItem item : new ArrayList<>(items)) { if (item != null) { item.setResearch(null); @@ -410,7 +419,9 @@ public static Optional getResearchByID(@Nonnull Integer oldID) { return Optional.empty(); } - return Slimefun.getRegistry().getResearches().parallelStream().filter(r -> r.id == oldID).findFirst(); + return Slimefun.getRegistry().getResearches().parallelStream() + .filter(r -> r.id == oldID) + .findFirst(); } @Override @@ -425,4 +436,4 @@ public double getCurrencyCost() { public void setCurrencyCost(double currencyCost) { this.currencyCost = currencyCost; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java index ba6cd3df54..8e1a33a4ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/researches/package-info.java @@ -2,4 +2,4 @@ * This package holds everything connected to the {@link io.github.thebusybiscuit.slimefun4.api.researches.Research} * class. */ -package io.github.thebusybiscuit.slimefun4.api.researches; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.api.researches; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java index 8c41ea176a..b22cb3324a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/SlimefunRegistry.java @@ -14,17 +14,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; -import me.mrCookieSlime.Slimefun.api.BlockInfoConfig; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; -import org.apache.commons.lang.Validate; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Entity; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Piglin; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; @@ -36,11 +25,21 @@ import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import javax.annotation.Nonnull; +import me.mrCookieSlime.Slimefun.api.BlockInfoConfig; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; +import org.apache.commons.lang.Validate; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Entity; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Piglin; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * This class houses a lot of instances of {@link Map} and {@link List} that hold * various mappings and collections related to {@link SlimefunItem}. - * + * * @author TheBusyBiscuit * */ @@ -92,7 +91,7 @@ public void load(@Nonnull Slimefun plugin) { /** * This returns a {@link List} containing every enabled {@link ItemGroup}. - * + * * @return {@link List} containing every enabled {@link ItemGroup} */ @Nonnull @@ -102,7 +101,7 @@ public List getAllItemGroups() { /** * This {@link List} contains every {@link SlimefunItem}, even disabled items. - * + * * @return A {@link List} containing every {@link SlimefunItem} */ public @Nonnull List getAllSlimefunItems() { @@ -123,7 +122,7 @@ public List getAllItemGroups() { /** * This {@link List} contains every enabled {@link SlimefunItem}. - * + * * @return A {@link List} containing every enabled {@link SlimefunItem} */ @Nonnull @@ -133,7 +132,7 @@ public List getEnabledSlimefunItems() { /** * This returns a {@link List} containing every enabled {@link Research}. - * + * * @return A {@link List} containing every enabled {@link Research} */ @Nonnull @@ -144,7 +143,7 @@ public List getResearches() { /** * This method returns a {@link Set} containing the {@link UUID} of every * {@link Player} who is currently unlocking a {@link Research}. - * + * * @return A {@link Set} holding the {@link UUID} from every {@link Player} * who is currently unlocking a {@link Research} */ @@ -160,7 +159,7 @@ public List getResearchRanks() { /** * This method returns a {@link List} of every enabled {@link MultiBlock}. - * + * * @return A {@link List} containing every enabled {@link MultiBlock} */ @Nonnull @@ -175,10 +174,10 @@ public List getMultiBlocks() { * This mainly only exists for internal purposes, if you want to open a certain section * using the {@link SlimefunGuide}, then please use the static methods provided in the * {@link SlimefunGuide} class. - * + * * @param mode * The {@link SlimefunGuideMode} - * + * * @return The corresponding {@link SlimefunGuideImplementation} */ @Nonnull @@ -197,7 +196,7 @@ public SlimefunGuideImplementation getSlimefunGuide(@Nonnull SlimefunGuideMode m /** * This returns a {@link Map} connecting the {@link EntityType} with a {@link Set} * of {@link ItemStack ItemStacks} which would be dropped when an {@link Entity} of that type was killed. - * + * * @return The {@link Map} of custom mob drops */ @Nonnull @@ -208,7 +207,7 @@ public Map> getMobDrops() { /** * This returns a {@link Set} of {@link ItemStack ItemStacks} which can be obtained by bartering * with {@link Piglin Piglins}. - * + * * @return A {@link Set} of bartering drops */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java index 05694f3e64..6a4fae9115 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java @@ -1,8 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm; import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.bukkit.Sound; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.Player; @@ -10,22 +12,18 @@ import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.ItemMeta; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm; - /** * This interface, when attached to a {@link SlimefunItem}, provides an easy method for damaging * an {@link ItemStack}, see {@link #damageItem(Player, ItemStack)}. - * + * * It also provides a simple {@link #isDamageable()} method, in case you wanna add a config * option that decides whether or not this {@link SlimefunItem} shall be damageable. - * + * * @author TheBusyBiscuit * @author RobotHanzo - * + * * @see UnbreakingAlgorithm - * + * */ public interface DamageableItem extends ItemAttribute { @@ -33,7 +31,7 @@ public interface DamageableItem extends ItemAttribute { * Implement this method to make the behaviour of this interface dependent * on the state of your object. * You could add a {@link Config} option to toggle the behaviour for example. - * + * * @return Whether this {@link SlimefunItem} is damageable */ boolean isDamageable(); @@ -41,9 +39,9 @@ public interface DamageableItem extends ItemAttribute { /** * This method will damage the given {@link ItemStack} once. * It also takes into account the {@link Enchantment} {@code Unbreaking}. - * + * * It will only apply the damage if {@link #isDamageable()} returned true. - * + * * @param p * The {@link Player} to which the item belongs * @param item @@ -82,12 +80,11 @@ default void damageItem(@Nonnull Player p, @Nullable ItemStack item) { * * @param unbreakingLevel * The {@link Integer} level of the unbreaking {@link Enchantment} - * + * * @return Whether to save the item from taking damage * */ default boolean evaluateUnbreakingEnchantment(int unbreakingLevel) { return UnbreakingAlgorithm.TOOLS.evaluate(unbreakingLevel); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java index 150bef8319..c8297065f9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DistinctiveItem.java @@ -1,12 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; -import org.bukkit.inventory.meta.ItemMeta; - -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - import javax.annotation.Nonnull; +import org.bukkit.inventory.meta.ItemMeta; /** * Implement this interface for any {@link SlimefunItem} to prevent diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java index cafe3bd812..30aef09c33 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java @@ -20,12 +20,12 @@ * This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks * the Item as an electric Block. * This will make this Block interact with an {@link EnergyNet}. - * + * * You can specify the Type of Block via {@link EnergyNetComponent#getEnergyComponentType()}. * You can also specify a capacity for this Block via {@link EnergyNetComponent#getCapacity()}. - * + * * @author TheBusyBiscuit - * + * * @see EnergyNetComponentType * @see EnergyNet * @@ -35,7 +35,7 @@ public interface EnergyNetComponent extends ItemAttribute { /** * This method returns the Type of {@link EnergyNetComponentType} this {@link SlimefunItem} represents. * It describes how this Block will interact with an {@link EnergyNet}. - * + * * @return The {@link EnergyNetComponentType} this {@link SlimefunItem} represents. */ @Nonnull @@ -44,7 +44,7 @@ public interface EnergyNetComponent extends ItemAttribute { /** * This method returns the max amount of electricity this Block can hold. * If the capacity is zero, then this Block cannot hold any electricity. - * + * * @return The max amount of electricity this Block can store. */ int getCapacity(); @@ -52,7 +52,7 @@ public interface EnergyNetComponent extends ItemAttribute { /** * This returns whether this {@link EnergyNetComponent} can hold energy charges. * It returns true if {@link #getCapacity()} returns a number greater than zero. - * + * * @return Whether this {@link EnergyNetComponent} can store energy. */ default boolean isChargeable() { @@ -61,10 +61,10 @@ default boolean isChargeable() { /** * This returns the currently stored charge at a given {@link Location}. - * + * * @param l * The target {@link Location} - * + * * @return The charge stored at that {@link Location} */ default int getCharge(@Nonnull Location l) { @@ -118,7 +118,7 @@ default int getCharge(@Nonnull Location l, @Nonnull Config config) { * The target {@link Location} * @param data * The data at this {@link Location} - * + * * @return The charge stored at that {@link Location} */ default int getCharge(@Nonnull Location l, @Nonnull SlimefunBlockData data) { @@ -143,7 +143,7 @@ default int getCharge(@Nonnull Location l, @Nonnull SlimefunBlockData data) { * This method sets the charge which is stored at a given {@link Location} * If this {@link EnergyNetComponent} is of type {@code EnergyNetComponentType.CAPACITOR}, then * this method will automatically update the texture of this {@link Capacitor} as well. - * + * * @param l * The target {@link Location} * @param charge @@ -182,7 +182,14 @@ default void setCharge(@Nonnull Location l, int charge) { } } } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to set the energy-charge for \"" + getId() + "\" at " + new BlockPosition(l)); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "Exception while trying to set the energy-charge for \"" + + getId() + + "\" at " + + new BlockPosition(l)); } } @@ -209,7 +216,14 @@ default void addCharge(@Nonnull Location l, int charge) { } } } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to add an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l)); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "Exception while trying to add an energy-charge for \"" + + getId() + + "\" at " + + new BlockPosition(l)); } } @@ -236,8 +250,14 @@ default void removeCharge(@Nonnull Location l, int charge) { } } } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to remove an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l)); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "Exception while trying to remove an energy-charge for \"" + + getId() + + "\" at " + + new BlockPosition(l)); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java index f26a9d32cd..57211bffd1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetProvider.java @@ -6,12 +6,11 @@ import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; +import javax.annotation.Nonnull; import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import org.bukkit.Location; -import javax.annotation.Nonnull; - /** * An {@link EnergyNetProvider} is an extension of {@link EnergyNetComponent} which provides * energy to an {@link EnergyNet}. @@ -64,5 +63,4 @@ default boolean willExplode(@Nonnull Location l, @Nonnull SlimefunBlockData data default boolean willExplode(@Nonnull Location l, @Nonnull Config data) { return false; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java index 8204409886..fe4b0f7181 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ExternallyInteractable.java @@ -2,9 +2,8 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.attributes.interactions.InteractionResult; -import org.bukkit.Location; - import javax.annotation.Nonnull; +import org.bukkit.Location; /** * Implement this interface for any {@link SlimefunItem} to provide methods for @@ -26,5 +25,4 @@ public interface ExternallyInteractable { */ @Nonnull InteractionResult onInteract(@Nonnull Location location); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java index b14e32c35c..71cbe53a67 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/HologramOwner.java @@ -1,21 +1,19 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import javax.annotation.Nonnull; - -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.util.Vector; - import io.github.bakedlibs.dough.common.ChatColors; import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector; +import javax.annotation.Nonnull; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.util.Vector; /** * This {@link ItemAttribute} manages holograms. - * + * * @author TheBusyBiscuit - * + * * @see HologramProjector * @see HologramsService * @@ -24,10 +22,10 @@ public interface HologramOwner extends ItemAttribute { /** * This will update the hologram text for the given {@link Block}. - * + * * @param b * The {@link Block} to which the hologram belongs - * + * * @param text * The nametag for the hologram */ @@ -38,7 +36,7 @@ default void updateHologram(@Nonnull Block b, @Nonnull String text) { /** * This will remove the hologram for the given {@link Block}. - * + * * @param b * The {@link Block} to which the hologram blocks */ @@ -51,15 +49,14 @@ default void removeHologram(@Nonnull Block b) { * This returns the offset of the hologram as a {@link Vector}. * This offset is applied to {@link Block#getLocation()} when spawning * the hologram. - * + * * @param block * The {@link Block} which serves as the origin point - * + * * @return The hologram offset */ @Nonnull default Vector getHologramOffset(@Nonnull Block block) { return Slimefun.getHologramsService().getDefaultOffset(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java index 44236086ba..cc2b2bcad8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ItemAttribute.java @@ -1,18 +1,17 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import javax.annotation.Nonnull; - import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import javax.annotation.Nonnull; /** * An empty interface that only serves the purpose of bundling together all * interfaces of that kind. - * + * * An {@link ItemAttribute} must be attached to a {@link SlimefunItem}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunItem * @see ItemHandler * @@ -26,5 +25,4 @@ public interface ItemAttribute { */ @Nonnull String getId(); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java index 8c0ecfe111..677a68f65b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineProcessHolder.java @@ -1,10 +1,9 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import javax.annotation.Nonnull; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation; import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; +import javax.annotation.Nonnull; /** * This {@link ItemAttribute} marks a {@link SlimefunItem} as a {@link MachineProcessHolder}. @@ -25,5 +24,4 @@ public interface MachineProcessHolder extends ItemAt */ @Nonnull MachineProcessor getMachineProcessor(); - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java index 212e1633b6..834e848bd2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineTier.java @@ -3,7 +3,6 @@ import javax.annotation.Nonnull; public enum MachineTier { - BASIC("&e基础"), AVERAGE("&6普通"), MEDIUM("&a中型"), @@ -21,5 +20,4 @@ public enum MachineTier { public String toString() { return prefix; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java index 68ff057ef4..99e729e4d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java @@ -3,7 +3,6 @@ import javax.annotation.Nonnull; public enum MachineType { - CAPACITOR("电容"), GENERATOR("发电机"), MACHINE("机器"); @@ -18,5 +17,4 @@ public enum MachineType { public String toString() { return suffix; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java index 2cea1d2f8d..3fb990ce48 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotConfigurable.java @@ -8,6 +8,4 @@ * * @author TheBusyBiscuit */ -public interface NotConfigurable extends ItemAttribute { - -} \ No newline at end of file +public interface NotConfigurable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java index 00d23a2a5e..1c46aa8455 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotHopperable.java @@ -8,6 +8,4 @@ * * @author CURVX */ -public interface NotHopperable extends ItemAttribute { - -} \ No newline at end of file +public interface NotHopperable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java index 464e91b911..26312fce88 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/NotPlaceable.java @@ -1,21 +1,18 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import org.bukkit.block.Block; import org.bukkit.event.block.BlockPlaceEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * Implement this interface for any {@link SlimefunItem} to prevent * that {@link SlimefunItem} from being placed. - * + * * Important: This will not cancel any {@link BlockPlaceEvent}. * It will simply prevent Slimefun from ever registering this {@link SlimefunItem} * as a placed {@link Block}. - * + * * @author TheBusyBiscuit * */ -public interface NotPlaceable extends ItemAttribute { - -} +public interface NotPlaceable extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java index cda9536f8b..ba968bd38b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/PiglinBarterDrop.java @@ -1,21 +1,20 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import org.bukkit.entity.Piglin; -import org.bukkit.event.entity.EntityDropItemEvent; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.PiglinListener; +import org.bukkit.entity.Piglin; +import org.bukkit.event.entity.EntityDropItemEvent; /** * This interface, when attached to a {@link SlimefunItem}, provides a variable (0-100%) chance for * a {@link SlimefunItem} to be dropped by a {@link Piglin} on {@link EntityDropItemEvent}. - * + * * @author dNiym * * @see PiglinListener * @see RandomMobDrop - * + * */ public interface PiglinBarterDrop extends ItemAttribute { @@ -27,9 +26,8 @@ public interface PiglinBarterDrop extends ItemAttribute { * It is recommended that this chance is kept reasonably low to feel like * a vanilla drop as a 100% chance will completely override all {@link Piglin} * barter drops. (NOTE: this feature only exists in 1.16+) - * + * * @return The integer chance (1-99%) this {@link SlimefunItem} has to drop. */ int getBarteringLootChance(); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java index 28130d102e..7edaa74270 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Placeable.java @@ -1,20 +1,17 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.Collection; - import javax.annotation.Nonnull; - import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * DO NOT IMPLEMENT THIS INTERFACE * This is implemented by every {@link SlimefunItem} by default. * Might be changed in the future. - * + * * @author TheBusyBiscuit * */ @@ -31,14 +28,13 @@ public interface Placeable { * If true is returned then it will be treated as a vanilla {@link Block}. * If false is returned then Slimefun will treat it as a {@link Block} that is * the placed down version of a {@link SlimefunItem}. - * + * * It returns false by default. * This was previously represented by the HandledBlock class. - * + * * @return Whether to use the vanilla block breaking behaviour */ default boolean useVanillaBlockBreaking() { return false; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java index 21f962e45a..68f38bf5c3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectionType.java @@ -26,5 +26,4 @@ public enum ProtectionType { * This damage type represents damage caused by flying into a wall with an elytra */ FLYING_INTO_WALL; - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java index 11aebe179a..2e867ad3eb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/ProtectiveArmor.java @@ -2,11 +2,10 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Player; - import javax.annotation.Nonnull; import javax.annotation.Nullable; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; /** * Implement this interface to a {@link SlimefunArmorPiece} to protect @@ -45,6 +44,5 @@ public interface ProtectiveArmor extends ItemAttribute { * * @return The set {@link NamespacedKey}, null if none is found. */ - @Nullable - NamespacedKey getArmorSetId(); -} \ No newline at end of file + @Nullable NamespacedKey getArmorSetId(); +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java index 2c703de40b..b8e1c0d6fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RadiationSymptom.java @@ -1,16 +1,13 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import javax.annotation.Nonnull; - import com.google.common.base.Preconditions; - +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; +import javax.annotation.Nonnull; import org.bukkit.entity.Player; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.RadiationUtils; - /** * An enum of potential radiation symptoms. * A symptom will be applied when the minExposure @@ -24,7 +21,6 @@ * @see RadiationUtils */ public enum RadiationSymptom { - SLOW(10, PotionEffectType.SLOW, 3), WITHER_LOW(25, PotionEffectType.WITHER, 0), BLINDNESS(50, PotionEffectType.BLINDNESS, 4), @@ -40,7 +36,8 @@ public enum RadiationSymptom { Preconditions.checkArgument(level >= 0, "The status effect level must be non-negative."); this.minExposure = minExposure; - this.potionEffect = new PotionEffect(type, Slimefun.getCfg().getOrSetDefault("options.radiation-update-interval", 1) * 20 + 20, level); + this.potionEffect = new PotionEffect( + type, Slimefun.getCfg().getOrSetDefault("options.radiation-update-interval", 1) * 20 + 20, level); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java index 22b09378d0..7f01d727ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactive.java @@ -1,16 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import javax.annotation.Nonnull; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import javax.annotation.Nonnull; /** * This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks * the Item as radioactive. * Carrying such an item will give the wearer the radiation effect. - * + * * You can specify a level of {@link Radioactivity} for the severity of the effect. - * + * * @author TheBusyBiscuit * */ @@ -19,10 +18,9 @@ public interface Radioactive extends ItemAttribute { /** * This method returns the level of {@link Radioactivity} for this {@link Radioactive} item. * Higher levels cause more severe radiation effects. - * + * * @return The level of {@link Radioactivity} of this item. */ @Nonnull Radioactivity getRadioactivity(); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java index aec100ad30..9ce090bb8c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Radioactivity.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - -import io.github.thebusybiscuit.slimefun4.implementation.tasks.armor.RadiationTask; - import org.bukkit.ChatColor; import org.bukkit.entity.Player; /** * This enum holds all available levels of {@link Radioactivity}. * The higher the level the more severe the effect of radiation will be. - * + * * @author TheBusyBiscuit - * + * * @see Radioactive * */ @@ -79,13 +77,12 @@ public int getExposureModifier() { /** * This method returns the level for the radiation effect to use in conjunction * with this level of {@link Radioactive}. - * + * * It is basically the index of this enum constant. - * + * * @return The level of radiation associated with this constant. */ public int getRadiationLevel() { return ordinal() + 1; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java index a0e51fe32d..97e9dfb69e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RandomMobDrop.java @@ -1,25 +1,24 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Player; -import org.bukkit.event.entity.EntityDeathEvent; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard; import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener; +import org.bukkit.entity.EntityType; +import org.bukkit.entity.Player; +import org.bukkit.event.entity.EntityDeathEvent; /** * This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding * a % chance to drop for an {@link SlimefunItem} on {@link EntityDeathEvent}, this chance is 0-100 * and used in conjunction with the {@link RecipeType#MOB_DROP}. - * + * * @author dNiym * * @see BasicCircuitBoard * @see MobDropListener * @see PiglinBarterDrop - * + * */ public interface RandomMobDrop extends ItemAttribute { @@ -27,9 +26,8 @@ public interface RandomMobDrop extends ItemAttribute { * Implement this method to make the object have a variable chance of being * added to the dropList when {@link EntityType} specified in * the {@link RecipeType#MOB_DROP} is killed by the {@link Player}. - * + * * @return The integer chance (0-100%) {@link SlimefunItem} has to drop. */ int getMobDropChance(); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java index 52081d5dfd..fea9a18beb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Rechargeable.java @@ -1,16 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import org.apache.commons.lang.Validate; -import org.bukkit.Material; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.MultiTool; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ChargingBench; import io.github.thebusybiscuit.slimefun4.utils.ChargeUtils; +import org.apache.commons.lang.Validate; +import org.bukkit.Material; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; /** * A {@link Rechargeable} {@link SlimefunItem} can hold energy and is able to @@ -146,5 +145,4 @@ default boolean removeItemCharge(ItemStack item, float charge) { item.setItemMeta(meta); return true; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java index c85cce7f3f..f18b0c3fa3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/RecipeDisplayItem.java @@ -1,30 +1,26 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; -import java.util.List; - -import javax.annotation.Nonnull; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner; import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan; - +import java.util.List; +import javax.annotation.Nonnull; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * This interface, when attache to a {@link SlimefunItem} class will make additional items * appear in the {@link SlimefunGuide}. * These additional items can be used represent recipes or resources that are associated * with this {@link SlimefunItem}. - * + * * You can find a few examples below. - * + * * @author TheBusyBiscuit - * + * * @see GoldPan * @see GEOMiner * @see AGenerator @@ -37,7 +33,7 @@ public interface RecipeDisplayItem extends ItemAttribute { * Note that these items will be filled in from top to bottom first. * So if you want it to express a recipe, add your input {@link ItemStack} * and then your output {@link ItemStack}. - * + * * @return The recipes to display in the {@link SlimefunGuide} */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java index a1534f5aa4..b4a112656c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/Soulbound.java @@ -11,6 +11,4 @@ * @author TheBusyBiscuit * @see SoulboundItem */ -public interface Soulbound extends ItemAttribute { - -} +public interface Soulbound extends ItemAttribute {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java index 712f0df3ea..47f90f1754 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/WitherProof.java @@ -1,20 +1,18 @@ package io.github.thebusybiscuit.slimefun4.core.attributes; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock; import javax.annotation.Nonnull; - import org.bukkit.block.Block; import org.bukkit.entity.Wither; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock; - /** * This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks * the Item as "Wither-Proof". * Wither-Proof blocks cannot be destroyed by a {@link Wither}. - * + * * @author TheBusyBiscuit - * + * * @see WitherProofBlock * */ @@ -23,12 +21,11 @@ public interface WitherProof extends ItemAttribute { /** * This method is called when a {@link Wither} tried to attack the given {@link Block}. * You can use this method to play particles or even damage the {@link Wither}. - * + * * @param block * The {@link Block} which was attacked. * @param wither * The {@link Wither} who attacked. */ void onAttack(@Nonnull Block block, @Nonnull Wither wither); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java index d0b36ae606..c23255905b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/InteractionResult.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable; - import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java index 3d93ffaf01..f2832ee6c1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/ItemInteractionResult.java @@ -1,12 +1,11 @@ package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; import io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; import java.util.Collections; import java.util.HashSet; import java.util.Set; +import javax.annotation.Nonnull; +import org.bukkit.inventory.ItemStack; /** * This class represents the result of an interaction on an {@link ExternallyInteractable} item. diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java index c8d0bf92b1..8155ee3eb6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/interactions/package-info.java @@ -2,4 +2,4 @@ * This package contains the various possible {@link io.github.thebusybiscuit.slimefun4.core.attributes.interactions.InteractionResult}s * that can be returned by an {@link io.github.thebusybiscuit.slimefun4.core.attributes.ExternallyInteractable} object. */ -package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.attributes.interactions; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java index 9a2c8c5699..cd73218db6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/package-info.java @@ -2,4 +2,4 @@ * This package contains all variations of {@link io.github.thebusybiscuit.slimefun4.core.attributes.ItemAttribute} that * can be assigned to a {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} */ -package io.github.thebusybiscuit.slimefun4.core.attributes; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.attributes; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java index a0747bc5fc..eb03665794 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunCommand.java @@ -1,13 +1,14 @@ package io.github.thebusybiscuit.slimefun4.core.commands; +import io.github.bakedlibs.dough.common.ChatColors; +import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; - import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -16,14 +17,11 @@ import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerCommandPreprocessEvent; -import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * This {@link CommandExecutor} holds the functionality of our {@code /slimefun} command. * * @author TheBusyBiscuit + * */ public class SlimefunCommand implements CommandExecutor, Listener { @@ -116,10 +114,7 @@ public void onCommand(PlayerCommandPreprocessEvent e) { */ public @Nonnull List getSubCommandNames() { // @formatter:off - return commands.stream() - .map(SubCommand::getName) - .collect(Collectors.toList()); + return commands.stream().map(SubCommand::getName).collect(Collectors.toList()); // @formatter:on } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index 80b2712891..4a3f45490a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -1,24 +1,20 @@ package io.github.thebusybiscuit.slimefun4.core.commands; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.researches.Research; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.LinkedList; import java.util.List; import java.util.Locale; -import java.util.stream.Collectors; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.researches.Research; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - class SlimefunTabCompleter implements TabCompleter { private static final int MAX_SUGGESTIONS = 80; @@ -29,20 +25,10 @@ public SlimefunTabCompleter(@Nonnull SlimefunCommand command) { this.command = command; } - @Nullable - @Override + @Nullable @Override public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { if (args.length == 1) { return createReturnList(command.getSubCommandNames(), args[0]); - } else if (args.length == 2) { - if (args[0].equalsIgnoreCase("banitem")) { - return createReturnList(getSlimefunItems(), args[1]); - } - else if (args[0].equalsIgnoreCase("unbanitem")) { - List list = Slimefun.getRegistry().getDisabledSlimefunItems().stream().map(sfItem -> sfItem.getId()).collect(Collectors.toList()); - return createReturnList(list, args[1]); - } - return null; } else if (args.length == 3) { if (args[0].equalsIgnoreCase("give")) { return createReturnList(getSlimefunItems(), args[2]); @@ -81,7 +67,7 @@ else if (args[0].equalsIgnoreCase("unbanitem")) { */ @Nonnull private List createReturnList(@Nonnull List list, @Nonnull String string) { - if (string.isEmpty()) { + if (string.length() == 0) { return list; } @@ -114,5 +100,4 @@ private List getSlimefunItems() { return list; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java index 4b5717a7a6..207d7c8772 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java @@ -1,24 +1,21 @@ package io.github.thebusybiscuit.slimefun4.core.commands; +import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.Map; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.defaults.HelpCommand; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * This class represents a {@link SubCommand}, it is a {@link Command} that starts with * {@code /sf ...} and is followed by the name of this {@link SubCommand}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunCommand * */ @@ -42,7 +39,7 @@ protected SubCommand(Slimefun plugin, SlimefunCommand cmd, String name, boolean /** * This returns the name of this {@link SubCommand}, the name is equivalent to the * first argument given to the actual command. - * + * * @return The name of this {@link SubCommand} */ @Nonnull @@ -52,7 +49,7 @@ public final String getName() { /** * This method returns whether this {@link SubCommand} is hidden from the {@link HelpCommand}. - * + * * @return Whether to hide this {@link SubCommand} */ public final boolean isHidden() { @@ -74,10 +71,10 @@ protected String getDescription() { * This returns a description for this {@link SubCommand}. * If the given {@link CommandSender} is a {@link Player}, the description * will be localized with the currently selected {@link Language} of that {@link Player}. - * + * * @param sender * The {@link CommandSender} who requested the description - * + * * @return A possibly localized description of this {@link SubCommand} */ public @Nonnull String getDescription(@Nonnull CommandSender sender) { @@ -87,5 +84,4 @@ protected String getDescription() { return Slimefun.getLocalization().getMessage(getDescription()); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java index 13a08a12ac..54639a4aaf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/package-info.java @@ -1,4 +1,4 @@ /** * This package contains everything related to Slimefun's ingame command. */ -package io.github.thebusybiscuit.slimefun4.core.commands; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.commands; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java index ae222fe81c..25ee7949a4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java @@ -47,13 +47,19 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { if (sender instanceof Player player) { if (sender.hasPermission("slimefun.command.backpack")) { if (args.length < 1) { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack (玩家名)")); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf backpack (玩家名)")); return; } if (args.length == 2) { if (sender.hasPermission("slimefun.command.backpack.other")) { - Slimefun.getDatabaseManager().getProfileDataController() + Slimefun.getDatabaseManager() + .getProfileDataController() .getPlayerUuidAsync(args[1], new IAsyncReadCallback<>() { @Override public void onResult(UUID result) { @@ -65,7 +71,8 @@ public void onResult(UUID result) { @Override public void onResultNotFound() { - Slimefun.getLocalization().sendMessage(player, "commands.backpack.backpack-does-not-exist"); + Slimefun.getLocalization() + .sendMessage(player, "commands.backpack.backpack-does-not-exist"); } }); } else { @@ -88,7 +95,8 @@ public void onResultNotFound() { private void openBackpackMenu(@Nonnull OfflinePlayer owner, @Nonnull Player p) { Validate.notNull(p, "The player cannot be null!"); - Slimefun.getDatabaseManager().getProfileDataController() + Slimefun.getDatabaseManager() + .getProfileDataController() .getBackpacksAsync(owner.getUniqueId().toString(), new IAsyncReadCallback<>() { @Override public boolean runOnMainThread() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java index 4a1fdaeb96..7c2c1160bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BlockDataCommand.java @@ -4,14 +4,13 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; import net.guizhanss.slimefun4.utils.ChatUtils; import org.bukkit.FluidCollisionMode; import org.bukkit.block.Block; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import javax.annotation.ParametersAreNonnullByDefault; - /** * 该指令可直接对 Slimefun 方块数据进行设置。 * @@ -41,9 +40,12 @@ public void onExecute(CommandSender sender, String[] args) { } if (args.length < 3) { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, - msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]") - ); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]")); return; } @@ -60,15 +62,17 @@ public void onExecute(CommandSender sender, String[] args) { switch (args[1]) { case "get" -> { String value = blockData.getData(key); - ChatUtils.sendMessage(player, "&a该方块 &b%key% &a的值为: &e%value%", - msg -> msg.replace("%key%", key).replace("%value%", value) - ); + ChatUtils.sendMessage(player, "&a该方块 &b%key% &a的值为: &e%value%", msg -> msg.replace("%key%", key) + .replace("%value%", value)); } case "set" -> { if (args.length < 4) { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, - msg -> msg.replace("%usage%", "/sf blockdata set ") - ); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf blockdata set ")); return; } @@ -80,9 +84,8 @@ public void onExecute(CommandSender sender, String[] args) { String value = args[2]; blockData.setData(key, value); - ChatUtils.sendMessage(player, "&a已设置该方块 &b%key% &a的值为: &e%value%", - msg -> msg.replace("%key%", key).replace("%value%", value) - ); + ChatUtils.sendMessage(player, "&a已设置该方块 &b%key% &a的值为: &e%value%", msg -> msg.replace("%key%", key) + .replace("%value%", value)); } case "remove" -> { if (key.equalsIgnoreCase("id")) { @@ -91,16 +94,16 @@ public void onExecute(CommandSender sender, String[] args) { } blockData.removeData(key); - ChatUtils.sendMessage(player, "&a已移除该方块 &b%key% &a的值", - msg -> msg.replace("%key%", key) - ); + ChatUtils.sendMessage(player, "&a已移除该方块 &b%key% &a的值", msg -> msg.replace("%key%", key)); } default -> { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, - msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]") - ); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf blockdata get/set/remove [value]")); } } - } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java index 119091e1e6..85ed9706ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java @@ -1,16 +1,14 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java index 973ed1ee39..9c73d8ea58 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java @@ -1,14 +1,12 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; class CheatCommand extends SubCommand { @@ -29,5 +27,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java index bbb8bb0ea1..0c968f873d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugCommand.java @@ -1,58 +1,60 @@ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; - -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.debug.Debug; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import org.bukkit.command.CommandSender; - -import javax.annotation.Nonnull; - -/** - * The debug command will allow server owners to get information for us developers. - * We can put debug messages in the code and they can trigger it for us to see what exactly is going on. - * - * @author WalshyDev - */ -public class DebugCommand extends SubCommand { - - protected DebugCommand(@Nonnull Slimefun plugin, @Nonnull SlimefunCommand cmd) { - super(plugin, cmd, "debug", true); - } - - @Override - protected @Nonnull String getDescription() { - return "commands.debug.description"; - } - - @Override - public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { - if (!sender.hasPermission("slimefun.command.debug")) { - Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); - return; - } - - if (args.length == 1) { - String currentCase = String.join(", ", Debug.getTestCase()); - if (!currentCase.isEmpty()) { - Slimefun.getLocalization().sendMessage(sender, "commands.debug.current", true, msg -> msg.replace("%test_case%", currentCase)); - } else { - Slimefun.getLocalization().sendMessage(sender, "commands.debug.none-running", true); - } - return; - } - - String test = args[1]; - - switch (test.toLowerCase()) { - case "disable", "off" -> { - Debug.disableTestCase(); - Slimefun.getLocalization().sendMessage(sender, "commands.debug.disabled"); - } - default -> { - Debug.addTestCase(test); - Slimefun.getLocalization().sendMessage(sender, "commands.debug.running", msg -> msg.replace("%test%", test)); - } - } - } -} +package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; + +import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.core.debug.Debug; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.Nonnull; +import org.bukkit.command.CommandSender; + +/** + * The debug command will allow server owners to get information for us developers. + * We can put debug messages in the code and they can trigger it for us to see what exactly is going on. + * + * @author WalshyDev + */ +public class DebugCommand extends SubCommand { + + protected DebugCommand(@Nonnull Slimefun plugin, @Nonnull SlimefunCommand cmd) { + super(plugin, cmd, "debug", true); + } + + @Override + protected @Nonnull String getDescription() { + return "commands.debug.description"; + } + + @Override + public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { + if (!sender.hasPermission("slimefun.command.debug")) { + Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); + return; + } + + if (args.length == 1) { + String currentCase = String.join(", ", Debug.getTestCase()); + if (!currentCase.isEmpty()) { + Slimefun.getLocalization() + .sendMessage( + sender, "commands.debug.current", true, msg -> msg.replace("%test_case%", currentCase)); + } else { + Slimefun.getLocalization().sendMessage(sender, "commands.debug.none-running", true); + } + return; + } + + String test = args[1]; + + switch (test.toLowerCase()) { + case "disable", "off" -> { + Debug.disableTestCase(); + Slimefun.getLocalization().sendMessage(sender, "commands.debug.disabled"); + } + default -> { + Debug.addTestCase(test); + Slimefun.getLocalization() + .sendMessage(sender, "commands.debug.running", msg -> msg.replace("%test%", test)); + } + } + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java index cc79b113e6..ff47f612ab 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java @@ -1,14 +1,12 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; class DebugFishCommand extends SubCommand { @@ -25,5 +23,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java index 5d56959e84..5623ab1e5f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java @@ -1,15 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import java.util.Locale; -import java.util.Map; -import java.util.Optional; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.common.PlayerList; import io.github.bakedlibs.dough.items.CustomItemStack; @@ -18,6 +8,13 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.Locale; +import java.util.Map; +import java.util.Optional; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; class GiveCommand extends SubCommand { @@ -44,13 +41,28 @@ public void onExecute(CommandSender sender, String[] args) { if (sfItem != null) { giveItem(sender, p, sfItem, args); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.invalid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2])); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.invalid-item", + true, + msg -> msg.replace(PLACEHOLDER_ITEM, args[2])); } } else { - Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.not-online", + true, + msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); } } else { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf give [Amount]")); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf give [Amount]")); } } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); @@ -64,17 +76,28 @@ private void giveItem(CommandSender sender, Player p, SlimefunItem sfItem, Strin int amount = parseAmount(args); if (amount > 0) { - Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); - Map excess = p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount)); + Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace( + PLACEHOLDER_ITEM, sfItem.getItemName()) + .replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); + Map excess = + p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount)); if (Slimefun.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) { for (ItemStack is : excess.values()) { p.getWorld().dropItem(p.getLocation(), is); } } - Slimefun.getLocalization().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); + Slimefun.getLocalization() + .sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]) + .replace(PLACEHOLDER_ITEM, sfItem.getItemName()) + .replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.invalid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3])); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.invalid-amount", + true, + msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3])); } } } @@ -92,5 +115,4 @@ private int parseAmount(String[] args) { return amount; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java index 006744d6c7..00900940c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java @@ -1,15 +1,13 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; class GuideCommand extends SubCommand { @@ -31,5 +29,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java index b3e411d388..a36c5f2ab1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/HelpCommand.java @@ -1,12 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; - import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; class HelpCommand extends SubCommand { @@ -19,5 +17,4 @@ class HelpCommand extends SubCommand { public void onExecute(CommandSender sender, String[] args) { cmd.sendHelp(sender); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java index 7216f06ea5..e32b0b521a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/MigrateCommand.java @@ -58,8 +58,12 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { private void sendMigrateStatus(@Nonnull String migrateType, @Nonnull CommandSender sender, MigrateStatus status) { switch (status) { - case SUCCESS -> - Slimefun.getLocalization().sendMessage(sender, "commands.migrate.success", true, msg -> msg.replace("%migrate_type%", migrateType)); + case SUCCESS -> Slimefun.getLocalization() + .sendMessage( + sender, + "commands.migrate.success", + true, + msg -> msg.replace("%migrate_type%", migrateType)); case FAILED -> Slimefun.getLocalization().sendMessage(sender, "commands.migrate.failed", true); case MIGRATING -> Slimefun.getLocalization().sendMessage(sender, "commands.migrate.in-progress", true); case MIGRATED -> Slimefun.getLocalization().sendMessage(sender, "commands.migrate.already-migrated", true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java index 83db842925..7d5efc3317 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java @@ -1,15 +1,13 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; class OpenGuideCommand extends SubCommand { @@ -31,5 +29,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java index 3014f44c36..01e837c6b6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java @@ -54,13 +54,23 @@ public void onExecute(CommandSender sender, String[] args) { } }); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.not-online", + true, + msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); } } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); } } else { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf research ")); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf research ")); } } @@ -70,11 +80,14 @@ private void giveResearch(CommandSender sender, Player p, String input) { if (research.isPresent()) { research.get().unlock(p, true, player -> { - UnaryOperator variables = msg -> msg.replace(PLACEHOLDER_PLAYER, player.getName()).replace(PLACEHOLDER_RESEARCH, research.get().getName(player)); + UnaryOperator variables = msg -> msg.replace(PLACEHOLDER_PLAYER, player.getName()) + .replace(PLACEHOLDER_RESEARCH, research.get().getName(player)); Slimefun.getLocalization().sendMessage(player, "messages.give-research", true, variables); }); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.invalid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input)); + Slimefun.getLocalization() + .sendMessage( + sender, "messages.invalid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input)); } } @@ -82,7 +95,9 @@ private void giveResearch(CommandSender sender, Player p, String input) { private void researchAll(CommandSender sender, PlayerProfile profile, Player p) { for (Research res : Slimefun.getRegistry().getResearches()) { if (!profile.hasUnlocked(res)) { - Slimefun.getLocalization().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()).replace(PLACEHOLDER_RESEARCH, res.getName(p))); + Slimefun.getLocalization().sendMessage(sender, "messages.give-research", true, msg -> msg.replace( + PLACEHOLDER_PLAYER, p.getName()) + .replace(PLACEHOLDER_RESEARCH, res.getName(p))); } res.unlock(p, true); @@ -95,7 +110,8 @@ private void reset(PlayerProfile profile, Player p) { profile.setResearched(research, false); } - Slimefun.getLocalization().sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName())); + Slimefun.getLocalization() + .sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName())); } @Nonnull @@ -112,5 +128,4 @@ private Optional getResearchFromString(@Nonnull String input) { return Optional.empty(); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java index 9783518b17..18d70fb894 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java @@ -1,18 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; -import java.util.Arrays; - -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.Arrays; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; class SearchCommand extends SubCommand { @@ -27,9 +24,16 @@ public void onExecute(CommandSender sender, String[] args) { if (sender.hasPermission("slimefun.command.search")) { if (args.length > 1) { String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); - PlayerProfile.get(player, profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true)); + PlayerProfile.get( + player, + profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true)); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search ")); + Slimefun.getLocalization() + .sendMessage( + sender, + "messages.usage", + true, + msg -> msg.replace("%usage%", "/sf search ")); } } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); @@ -38,5 +42,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java index b22796c432..c3d6b60e28 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SlimefunSubCommands.java @@ -13,7 +13,7 @@ * This class holds the implementations of every {@link SubCommand}. * The implementations themselves are package-private, this class only provides * a static setup method - * + * * @author TheBusyBiscuit * */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java index c5ca79fcbf..0885e7ba98 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java @@ -33,7 +33,8 @@ public void onExecute(CommandSender sender, String[] args) { if (player.isPresent()) { PlayerProfile.get(player.get(), profile -> profile.sendStats(sender)); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1])); + Slimefun.getLocalization() + .sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1])); } } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true); @@ -44,5 +45,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java index 891ba85059..dc52c4fa32 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java @@ -1,17 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.block.BlockFace; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - class TeleporterCommand extends SubCommand { @ParametersAreNonnullByDefault @@ -24,19 +22,35 @@ public void onExecute(CommandSender sender, String[] args) { if (sender instanceof Player player) { if (sender.hasPermission("slimefun.command.teleporter")) { if (args.length == 1) { - Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI(player, player.getUniqueId(), player.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999); + Slimefun.getGPSNetwork() + .getTeleportationManager() + .openTeleporterGUI( + player, + player.getUniqueId(), + player.getLocation().getBlock().getRelative(BlockFace.DOWN), + 999999999); } else if (args.length == 2) { @SuppressWarnings("deprecation") OfflinePlayer targetPlayer = Bukkit.getOfflinePlayer(args[1]); if (targetPlayer.getName() != null) { - Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI(player, targetPlayer.getUniqueId(), player.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999); + Slimefun.getGPSNetwork() + .getTeleportationManager() + .openTeleporterGUI( + player, + targetPlayer.getUniqueId(), + player.getLocation().getBlock().getRelative(BlockFace.DOWN), + 999999999); } else { - Slimefun.getLocalization().sendMessage(sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1])); + Slimefun.getLocalization() + .sendMessage( + sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1])); } } else { - Slimefun.getLocalization().sendMessage(sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]")); + Slimefun.getLocalization() + .sendMessage( + sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]")); } } else { Slimefun.getLocalization().sendMessage(sender, "messages.no-permission"); @@ -45,5 +59,4 @@ public void onExecute(CommandSender sender, String[] args) { Slimefun.getLocalization().sendMessage(sender, "messages.only-players"); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java index 3dfd8a78cc..4e4666024f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java @@ -1,25 +1,22 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; +import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; +import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.ConsolePerformanceInspector; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.Arrays; import java.util.HashSet; import java.util.Locale; import java.util.Set; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; -import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.ConsolePerformanceInspector; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - class TimingsCommand extends SubCommand { private static final String FLAG_PREFIX = "--"; @@ -77,7 +74,9 @@ private boolean hasInvalidFlags(CommandSender sender, String[] args) { if (argument.startsWith(FLAG_PREFIX) && !flags.contains(argument.substring(2))) { hasInvalidFlags = true; - Slimefun.getLocalization().sendMessage(sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument)); + Slimefun.getLocalization() + .sendMessage( + sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java index cd6f050cf3..6237c2f219 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TransformCommand.java @@ -4,17 +4,16 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.logging.Level; import org.bukkit.Material; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.logging.Level; - class TransformCommand extends SubCommand { TransformCommand(Slimefun plugin, SlimefunCommand cmd) { super(plugin, cmd, "transform", false); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java index d217dd198b..b73c744cae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java @@ -21,7 +21,7 @@ /** * This is our class for the /sf versions subcommand. - * + * * @author TheBusyBiscuit * @author Walshy * @@ -80,12 +80,10 @@ public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) { addJavaVersion(builder); // Add notice to warn those smart people - builder.append("\n由 StarWishsama 汉化").color(ChatColor.WHITE) - .append( - "\n请不要将此版本信息截图到 Discord/Github 反馈 Bug" + - "\n优先到汉化页面反馈" + - "\n" - ).color(ChatColor.RED); + builder.append("\n由 StarWishsama 汉化") + .color(ChatColor.WHITE) + .append("\n请不要将此版本信息截图到 Discord/Github 反馈 Bug" + "\n优先到汉化页面反馈" + "\n") + .color(ChatColor.RED); builder.append("\n").event((HoverEvent) null); addPluginVersions(builder); @@ -101,17 +99,23 @@ private void addJavaVersion(@Nonnull ComponentBuilder builder) { if (version < RECOMMENDED_JAVA_VERSION) { // @formatter:off - builder.append("Java " + version).color(ChatColor.RED) - .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent( - "你使用的 Java 版本已过时!\n!" + - "推荐你使用 Java " + RECOMMENDED_JAVA_VERSION + " 或更高版本.\n" + - JAVA_VERSION_NOTICE - )})) + builder.append("Java " + version) + .color(ChatColor.RED) + .event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] { + new TextComponent("你使用的 Java 版本已过时!\n!" + + "推荐你使用 Java " + + RECOMMENDED_JAVA_VERSION + + " 或更高版本.\n" + + JAVA_VERSION_NOTICE) + })) .append("\n") .event((HoverEvent) null); // @formatter:on } else { - builder.append("Java ").color(ChatColor.GREEN).append(version + "\n").color(ChatColor.DARK_GREEN); + builder.append("Java ") + .color(ChatColor.GREEN) + .append(version + "\n") + .color(ChatColor.DARK_GREEN); } } @@ -123,7 +127,10 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) { return; } - builder.append("安装的附属插件: ").color(ChatColor.GRAY).append("(" + addons.size() + ")").color(ChatColor.DARK_GRAY); + builder.append("安装的附属插件: ") + .color(ChatColor.GRAY) + .append("(" + addons.size() + ")") + .color(ChatColor.DARK_GRAY); for (Plugin plugin : addons) { String version = plugin.getDescription().getVersion(); @@ -140,25 +147,27 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) { if (plugin instanceof SlimefunAddon addon && addon.getBugTrackerURL() != null) { // @formatter:off - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(new ComponentBuilder() - .append("作者: ") - .append(authors) - .color(ChatColor.YELLOW) - .append("\n> 单击打开反馈页面") - .color(ChatColor.GOLD) - .create() - )}); + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] { + new TextComponent(new ComponentBuilder() + .append("作者: ") + .append(authors) + .color(ChatColor.YELLOW) + .append("\n> 单击打开反馈页面") + .color(ChatColor.GOLD) + .create()) + }); // @formatter:on clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, addon.getBugTrackerURL()); } else { // @formatter:off - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(new ComponentBuilder() - .append("作者: ") - .append(authors) - .color(ChatColor.YELLOW) - .create() - )}); + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] { + new TextComponent(new ComponentBuilder() + .append("作者: ") + .append(authors) + .color(ChatColor.YELLOW) + .create()) + }); // @formatter:on } } else { @@ -167,20 +176,23 @@ private void addPluginVersions(@Nonnull ComponentBuilder builder) { if (plugin instanceof SlimefunAddon addon && addon.getBugTrackerURL() != null) { // @formatter:off - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent(new ComponentBuilder() - .append("此插件已被禁用.\n检查后台是否有报错.") - .color(ChatColor.RED) - .append("\n> 单击打开反馈页面") - .color(ChatColor.DARK_RED) - .create() - )}); + hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[] { + new TextComponent(new ComponentBuilder() + .append("此插件已被禁用.\n检查后台是否有报错.") + .color(ChatColor.RED) + .append("\n> 单击打开反馈页面") + .color(ChatColor.DARK_RED) + .create()) + }); // @formatter:on if (addon.getBugTrackerURL() != null) { clickEvent = new ClickEvent(ClickEvent.Action.OPEN_URL, addon.getBugTrackerURL()); } } else { - hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{new TextComponent("插件已被禁用. 可以看看后台是否有报错.")}); + hoverEvent = new HoverEvent( + HoverEvent.Action.SHOW_TEXT, + new TextComponent[] {new TextComponent("插件已被禁用. 可以看看后台是否有报错.")}); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java index c1b87ef5c7..4f8172faf8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/package-info.java @@ -2,4 +2,4 @@ * This package holds all implementations of {@link io.github.thebusybiscuit.slimefun4.core.commands.SubCommand}. * You can find all sub commands of Slimefun in here. */ -package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java index 82490ebc7b..25da8e027f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunConfigManager.java @@ -36,6 +36,7 @@ public class SlimefunConfigManager { * Hold research config named "Researches.yml" */ private final Config researchesConfig; + private boolean automaticallyLoadItems; private boolean enableResearches; private boolean freeCreativeResearches; @@ -58,13 +59,19 @@ public SlimefunConfigManager(@Nonnull Slimefun plugin) { researchesConfig = getConfig(plugin, "Researches", () -> new Config(plugin, "Researches.yml")); } - @Nullable - @ParametersAreNonnullByDefault + @Nullable @ParametersAreNonnullByDefault private Config getConfig(Slimefun plugin, String name, Supplier supplier) { try { return supplier.get(); } catch (Exception x) { - plugin.getLogger().log(Level.SEVERE, x, () -> "An Exception was thrown while loading the config file \"" + name + ".yml\" for Slimefun v" + plugin.getDescription().getVersion()); + plugin.getLogger() + .log( + Level.SEVERE, + x, + () -> "An Exception was thrown while loading the config file \"" + + name + + ".yml\" for Slimefun v" + + plugin.getDescription().getVersion()); return null; } } @@ -96,7 +103,12 @@ public boolean load(boolean reload) { researchesConfig.setDefaultValue("researches.currency-cost-convert-rate", 25.0); researchCurrencyCostConvertRate = researchesConfig.getDouble("researches.currency-cost-convert-rate"); } catch (Exception x) { - plugin.getLogger().log(Level.SEVERE, x, () -> "An Exception was caught while (re)loading the config files for Slimefun v" + plugin.getDescription().getVersion()); + plugin.getLogger() + .log( + Level.SEVERE, + x, + () -> "An Exception was caught while (re)loading the config files for Slimefun v" + + plugin.getDescription().getVersion()); isSuccessful = false; } @@ -122,7 +134,12 @@ public boolean load(boolean reload) { } } } catch (Exception x) { - plugin.getLogger().log(Level.SEVERE, x, () -> "Something went wrong while trying to update the cost of a research: " + research); + plugin.getLogger() + .log( + Level.SEVERE, + x, + () -> "Something went wrong while trying to update the cost of a research: " + + research); isSuccessful = false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java index b268e852f1..5afad85b84 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/config/SlimefunDatabaseManager.java @@ -1,200 +1,196 @@ -package io.github.thebusybiscuit.slimefun4.core.config; - -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlConfig; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlConfig; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteAdapter; -import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteConfig; -import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; -import com.xzavier0722.mc.plugin.slimefun4.storage.controller.BlockDataController; -import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ControllerHolder; -import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ChunkDataLoadMode; -import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ProfileDataController; -import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import java.io.File; -import java.io.IOException; -import java.util.logging.Level; -import javax.annotation.Nullable; - -public class SlimefunDatabaseManager { - private static final String PROFILE_CONFIG_FILE_NAME = "profile-storage.yml"; - private static final String BLOCK_STORAGE_FILE_NAME = "block-storage.yml"; - private final Slimefun plugin; - private final Config profileConfig; - private final Config blockStorageConfig; - private StorageType profileStorageType; - private StorageType blockDataStorageType; - private IDataSourceAdapter profileAdapter; - private IDataSourceAdapter blockStorageAdapter; - - - public SlimefunDatabaseManager(Slimefun plugin) { - this.plugin = plugin; - - if (!new File(plugin.getDataFolder(), PROFILE_CONFIG_FILE_NAME).exists()) { - plugin.saveResource(PROFILE_CONFIG_FILE_NAME, false); - } - - if (!new File(plugin.getDataFolder(), BLOCK_STORAGE_FILE_NAME).exists()) { - plugin.saveResource(BLOCK_STORAGE_FILE_NAME, false); - } - - profileConfig = new Config(plugin, PROFILE_CONFIG_FILE_NAME); - blockStorageConfig = new Config(plugin, BLOCK_STORAGE_FILE_NAME); - } - - public void init() { - initDefaultVal(); - try { - blockDataStorageType = StorageType.valueOf(blockStorageConfig.getString("storageType")); - var readExecutorThread = blockStorageConfig.getInt("readExecutorThread"); - var writeExecutorThread = blockStorageConfig.getInt("writeExecutorThread"); - - initAdapter(blockDataStorageType, DataType.BLOCK_STORAGE, blockStorageConfig); - - var blockDataController = ControllerHolder.createController(BlockDataController.class, blockDataStorageType); - blockDataController.init(blockStorageAdapter, readExecutorThread, writeExecutorThread); - - if (blockStorageConfig.getBoolean("delayedWriting.enable")) { - plugin.getLogger().log(Level.INFO, "已启用延时写入功能"); - blockDataController.initDelayedSaving( - plugin, - blockStorageConfig.getInt("delayedWriting.delayedSecond"), - blockStorageConfig.getInt("delayedWriting.forceSavePeriod") - ); - } - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "加载 Slimefun 方块存储适配器失败", e); - return; - } - - try { - profileStorageType = StorageType.valueOf(profileConfig.getString("storageType")); - var readExecutorThread = profileConfig.getInt("readExecutorThread"); - var writeExecutorThread = profileStorageType == StorageType.SQLITE ? 1 : profileConfig.getInt("writeExecutorThread"); - - initAdapter(profileStorageType, DataType.PLAYER_PROFILE, profileConfig); - var profileController = ControllerHolder.createController(ProfileDataController.class, profileStorageType); - profileController.init(profileAdapter, readExecutorThread, writeExecutorThread); - } catch (IOException e) { - plugin.getLogger().log(Level.SEVERE, "加载玩家档案适配器失败", e); - } - } - - private void initAdapter(StorageType storageType, DataType dataType, Config databaseConfig) throws IOException { - switch (storageType) { - case MYSQL -> { - var adapter = new MysqlAdapter(); - - adapter.prepare( - new MysqlConfig( - databaseConfig.getString("mysql.host"), - databaseConfig.getInt("mysql.port"), - databaseConfig.getString("mysql.database"), - databaseConfig.getString("mysql.tablePrefix"), - databaseConfig.getString("mysql.user"), - databaseConfig.getString("mysql.password"), - databaseConfig.getBoolean("mysql.useSSL"), - databaseConfig.getInt("mysql.maxConnection") - )); - - switch (dataType) { - case BLOCK_STORAGE -> blockStorageAdapter = adapter; - case PLAYER_PROFILE -> profileAdapter = adapter; - } - } - case SQLITE -> { - var adapter = new SqliteAdapter(); - - File databasePath = null; - - switch (dataType) { - case PLAYER_PROFILE -> { - databasePath = new File("data-storage/Slimefun", "profile.db"); - profileAdapter = adapter; - } - case BLOCK_STORAGE -> { - databasePath = new File("data-storage/Slimefun", "block-storage.db"); - blockStorageAdapter = adapter; - } - } - adapter.prepare(new SqliteConfig(databasePath.getAbsolutePath(), databaseConfig.getInt("sqlite.maxConnection"))); - } - case POSTGRESQL -> { - var adapter = new PostgreSqlAdapter(); - - adapter.prepare( - new PostgreSqlConfig( - databaseConfig.getString("postgresql.host"), - databaseConfig.getInt("postgresql.port"), - databaseConfig.getString("postgresql.database"), - databaseConfig.getString("postgresql.tablePrefix"), - databaseConfig.getString("postgresql.user"), - databaseConfig.getString("postgresql.password"), - databaseConfig.getBoolean("postgresql.useSSL"), - databaseConfig.getInt("postgresql.maxConnection") - )); - - switch (dataType) { - case BLOCK_STORAGE -> blockStorageAdapter = adapter; - case PLAYER_PROFILE -> profileAdapter = adapter; - } - } - } - } - - @Nullable - public ProfileDataController getProfileDataController() { - return ControllerHolder.getController(ProfileDataController.class, profileStorageType); - } - - public BlockDataController getBlockDataController() { - return ControllerHolder.getController(BlockDataController.class, blockDataStorageType); - } - - public void shutdown() { - if (getProfileDataController() != null) { - getProfileDataController().shutdown(); - } - - if (getBlockDataController() != null) { - getBlockDataController().shutdown(); - } - - blockStorageAdapter.shutdown(); - profileAdapter.shutdown(); - ControllerHolder.clearControllers(); - } - - public boolean isBlockDataBase64Enabled() { - return blockStorageConfig.getBoolean("base64EncodeVal"); - } - - public boolean isProfileDataBase64Enabled() { - return profileConfig.getBoolean("base64EncodeVal"); - } - - public ChunkDataLoadMode getChunkDataLoadMode() { - return ChunkDataLoadMode.valueOf(blockStorageConfig.getString("dataLoadMode")); - } - - public StorageType getBlockDataStorageType() { - return blockDataStorageType; - } - - public StorageType getProfileStorageType() { - return profileStorageType; - } - - private void initDefaultVal() { - profileConfig.setDefaultValue("sqlite.maxConnection", 5); - profileConfig.save(); - blockStorageConfig.setDefaultValue("sqlite.maxConnection", 5); - blockStorageConfig.setDefaultValue("dataLoadMode", "LOAD_WITH_CHUNK"); - blockStorageConfig.save(); - } -} +package io.github.thebusybiscuit.slimefun4.core.config; + +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.IDataSourceAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.mysql.MysqlConfig; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.postgresql.PostgreSqlConfig; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteAdapter; +import com.xzavier0722.mc.plugin.slimefun4.storage.adapter.sqlite.SqliteConfig; +import com.xzavier0722.mc.plugin.slimefun4.storage.common.DataType; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.BlockDataController; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ChunkDataLoadMode; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ControllerHolder; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.ProfileDataController; +import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.io.File; +import java.io.IOException; +import java.util.logging.Level; +import javax.annotation.Nullable; + +public class SlimefunDatabaseManager { + private static final String PROFILE_CONFIG_FILE_NAME = "profile-storage.yml"; + private static final String BLOCK_STORAGE_FILE_NAME = "block-storage.yml"; + private final Slimefun plugin; + private final Config profileConfig; + private final Config blockStorageConfig; + private StorageType profileStorageType; + private StorageType blockDataStorageType; + private IDataSourceAdapter profileAdapter; + private IDataSourceAdapter blockStorageAdapter; + + public SlimefunDatabaseManager(Slimefun plugin) { + this.plugin = plugin; + + if (!new File(plugin.getDataFolder(), PROFILE_CONFIG_FILE_NAME).exists()) { + plugin.saveResource(PROFILE_CONFIG_FILE_NAME, false); + } + + if (!new File(plugin.getDataFolder(), BLOCK_STORAGE_FILE_NAME).exists()) { + plugin.saveResource(BLOCK_STORAGE_FILE_NAME, false); + } + + profileConfig = new Config(plugin, PROFILE_CONFIG_FILE_NAME); + blockStorageConfig = new Config(plugin, BLOCK_STORAGE_FILE_NAME); + } + + public void init() { + initDefaultVal(); + try { + blockDataStorageType = StorageType.valueOf(blockStorageConfig.getString("storageType")); + var readExecutorThread = blockStorageConfig.getInt("readExecutorThread"); + var writeExecutorThread = blockStorageConfig.getInt("writeExecutorThread"); + + initAdapter(blockDataStorageType, DataType.BLOCK_STORAGE, blockStorageConfig); + + var blockDataController = + ControllerHolder.createController(BlockDataController.class, blockDataStorageType); + blockDataController.init(blockStorageAdapter, readExecutorThread, writeExecutorThread); + + if (blockStorageConfig.getBoolean("delayedWriting.enable")) { + plugin.getLogger().log(Level.INFO, "已启用延时写入功能"); + blockDataController.initDelayedSaving( + plugin, + blockStorageConfig.getInt("delayedWriting.delayedSecond"), + blockStorageConfig.getInt("delayedWriting.forceSavePeriod")); + } + } catch (IOException e) { + plugin.getLogger().log(Level.SEVERE, "加载 Slimefun 方块存储适配器失败", e); + return; + } + + try { + profileStorageType = StorageType.valueOf(profileConfig.getString("storageType")); + var readExecutorThread = profileConfig.getInt("readExecutorThread"); + var writeExecutorThread = + profileStorageType == StorageType.SQLITE ? 1 : profileConfig.getInt("writeExecutorThread"); + + initAdapter(profileStorageType, DataType.PLAYER_PROFILE, profileConfig); + var profileController = ControllerHolder.createController(ProfileDataController.class, profileStorageType); + profileController.init(profileAdapter, readExecutorThread, writeExecutorThread); + } catch (IOException e) { + plugin.getLogger().log(Level.SEVERE, "加载玩家档案适配器失败", e); + } + } + + private void initAdapter(StorageType storageType, DataType dataType, Config databaseConfig) throws IOException { + switch (storageType) { + case MYSQL -> { + var adapter = new MysqlAdapter(); + + adapter.prepare(new MysqlConfig( + databaseConfig.getString("mysql.host"), + databaseConfig.getInt("mysql.port"), + databaseConfig.getString("mysql.database"), + databaseConfig.getString("mysql.tablePrefix"), + databaseConfig.getString("mysql.user"), + databaseConfig.getString("mysql.password"), + databaseConfig.getBoolean("mysql.useSSL"), + databaseConfig.getInt("mysql.maxConnection"))); + + switch (dataType) { + case BLOCK_STORAGE -> blockStorageAdapter = adapter; + case PLAYER_PROFILE -> profileAdapter = adapter; + } + } + case SQLITE -> { + var adapter = new SqliteAdapter(); + + File databasePath = null; + + switch (dataType) { + case PLAYER_PROFILE -> { + databasePath = new File("data-storage/Slimefun", "profile.db"); + profileAdapter = adapter; + } + case BLOCK_STORAGE -> { + databasePath = new File("data-storage/Slimefun", "block-storage.db"); + blockStorageAdapter = adapter; + } + } + adapter.prepare(new SqliteConfig( + databasePath.getAbsolutePath(), databaseConfig.getInt("sqlite.maxConnection"))); + } + case POSTGRESQL -> { + var adapter = new PostgreSqlAdapter(); + + adapter.prepare(new PostgreSqlConfig( + databaseConfig.getString("postgresql.host"), + databaseConfig.getInt("postgresql.port"), + databaseConfig.getString("postgresql.database"), + databaseConfig.getString("postgresql.tablePrefix"), + databaseConfig.getString("postgresql.user"), + databaseConfig.getString("postgresql.password"), + databaseConfig.getBoolean("postgresql.useSSL"), + databaseConfig.getInt("postgresql.maxConnection"))); + + switch (dataType) { + case BLOCK_STORAGE -> blockStorageAdapter = adapter; + case PLAYER_PROFILE -> profileAdapter = adapter; + } + } + } + } + + @Nullable public ProfileDataController getProfileDataController() { + return ControllerHolder.getController(ProfileDataController.class, profileStorageType); + } + + public BlockDataController getBlockDataController() { + return ControllerHolder.getController(BlockDataController.class, blockDataStorageType); + } + + public void shutdown() { + if (getProfileDataController() != null) { + getProfileDataController().shutdown(); + } + + if (getBlockDataController() != null) { + getBlockDataController().shutdown(); + } + + blockStorageAdapter.shutdown(); + profileAdapter.shutdown(); + ControllerHolder.clearControllers(); + } + + public boolean isBlockDataBase64Enabled() { + return blockStorageConfig.getBoolean("base64EncodeVal"); + } + + public boolean isProfileDataBase64Enabled() { + return profileConfig.getBoolean("base64EncodeVal"); + } + + public ChunkDataLoadMode getChunkDataLoadMode() { + return ChunkDataLoadMode.valueOf(blockStorageConfig.getString("dataLoadMode")); + } + + public StorageType getBlockDataStorageType() { + return blockDataStorageType; + } + + public StorageType getProfileStorageType() { + return profileStorageType; + } + + private void initDefaultVal() { + profileConfig.setDefaultValue("sqlite.maxConnection", 5); + profileConfig.save(); + blockStorageConfig.setDefaultValue("sqlite.maxConnection", 5); + blockStorageConfig.setDefaultValue("dataLoadMode", "LOAD_WITH_CHUNK"); + blockStorageConfig.save(); + } +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java index ab9b53c0c8..0dd4ccec02 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/Debug.java @@ -76,9 +76,9 @@ public static void log(@Nonnull String test, @Nonnull String msg, @Nonnull Objec if (vars.length > 0) { String formatted = formatMessage(msg, vars); - Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] { test, formatted }); + Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] {test, formatted}); } else { - Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] { test, msg }); + Slimefun.logger().log(Level.INFO, "[DEBUG {0}] {1}", new Object[] {test, msg}); } } @@ -104,7 +104,8 @@ public static void log(@Nonnull String test, @Nonnull String msg, @Nonnull Objec // Find an opening curly brace `{` and validate the next char is a closing one `}` while ((i = msg.indexOf('{', i)) != -1 && msg.charAt(i + 1) == '}') { - // Substring up to the opening brace `{`, add the variable for this and add the rest of the message + // Substring up to the opening brace `{`, add the variable for this and add the rest of the + // message msg = msg.substring(0, i) + vars[idx] + msg.substring(i + 2); idx++; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java index 4a8941e34b..7c413f7b9f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/TestCase.java @@ -26,8 +26,7 @@ public enum TestCase { ENERGYNET; - TestCase() { - } + TestCase() {} @Override public @Nonnull String toString() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java index 57ef3809c0..f987069d28 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/debug/package-info.java @@ -2,4 +2,4 @@ * This package holds the debug functionality of Slimefun, these can be used as addons but are mostly just * going to be used by Slimefun itself. */ -package io.github.thebusybiscuit.slimefun4.core.debug; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.debug; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java index 114980eefa..adf84d2a9c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideEntry.java @@ -24,5 +24,4 @@ public int getPage() { public void setPage(int page) { this.page = page; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java index d84adcfee2..e0b81251ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java @@ -1,25 +1,22 @@ package io.github.thebusybiscuit.slimefun4.core.guide; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import java.util.Deque; import java.util.LinkedList; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; - /** * {@link GuideHistory} represents the browsing history of a {@link Player} through the * {@link SlimefunGuide}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunGuide * @see PlayerProfile * @@ -32,7 +29,7 @@ public class GuideHistory { /** * This creates a new {@link GuideHistory} for the given {@link PlayerProfile} - * + * * @param profile * The {@link PlayerProfile} this {@link GuideHistory} was made for */ @@ -50,7 +47,7 @@ public void clear() { /** * This method sets the page of the main menu of this {@link GuideHistory} - * + * * @param page * The current page of the main menu that should be stored */ @@ -62,7 +59,7 @@ public void setMainMenuPage(int page) { /** * This returns the current main menu page of this {@link GuideHistory} - * + * * @return The main menu page of this {@link GuideHistory} */ public int getMainMenuPage() { @@ -73,7 +70,7 @@ public int getMainMenuPage() { * This method adds a {@link ItemGroup} to this {@link GuideHistory}. * Should the {@link ItemGroup} already be the last element in this {@link GuideHistory}, * then the entry will be overridden with the new page. - * + * * @param itemGroup * The {@link ItemGroup} that should be added to this {@link GuideHistory} * @param page @@ -87,7 +84,7 @@ public void add(@Nonnull ItemGroup itemGroup, int page) { * This method adds a {@link ItemStack} to this {@link GuideHistory}. * Should the {@link ItemStack} already be the last element in this {@link GuideHistory}, * then the entry will be overridden with the new page. - * + * * @param item * The {@link ItemStack} that should be added to this {@link GuideHistory} * @param page @@ -99,7 +96,7 @@ public void add(@Nonnull ItemStack item, int page) { /** * This method stores the given {@link SlimefunItem} in this {@link GuideHistory}. - * + * * @param item * The {@link SlimefunItem} that should be added to this {@link GuideHistory} */ @@ -110,7 +107,7 @@ public void add(@Nonnull SlimefunItem item) { /** * This method stores the given search term in this {@link GuideHistory}. - * + * * @param searchTerm * The term that the {@link Player} searched for */ @@ -134,7 +131,7 @@ private void refresh(@Nonnull T object, int page) { /** * This returns the amount of elements in this {@link GuideHistory}. - * + * * @return The size of this {@link GuideHistory} */ public int size() { @@ -144,13 +141,12 @@ public int size() { /** * Retrieves the last page in the {@link SlimefunGuide} that was visited by a {@link Player}. * Optionally also rewinds the history back to that entry. - * + * * @param remove * Whether to remove the current entry so it moves back to the entry returned. * @return The last Guide Entry that was saved to the given Players guide history. */ - @Nullable - private GuideEntry getLastEntry(boolean remove) { + @Nullable private GuideEntry getLastEntry(boolean remove) { if (remove && !queue.isEmpty()) { queue.removeLast(); } @@ -161,7 +157,7 @@ private GuideEntry getLastEntry(boolean remove) { /** * This method opens the last opened entry to the associated {@link PlayerProfile} * of this {@link GuideHistory}. - * + * * @param guide * The {@link SlimefunGuideImplementation} to use */ @@ -174,9 +170,9 @@ public void openLastEntry(@Nonnull SlimefunGuideImplementation guide) { * This method opens the previous entry to the associated {@link PlayerProfile}. * More precisely, it will remove the last entry and open the second-last entry * to the {@link Player}. - * + * * It can be thought of as a "back" button. Since that is what this is used for. - * + * * @param guide * The {@link SlimefunGuideImplementation} to use */ @@ -200,5 +196,4 @@ private void open(@Nonnull SlimefunGuideImplementation guide, @Nullable Guid throw new IllegalStateException("Unknown GuideHistory entry: " + entry.getIndexedObject()); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index 91f70a6c80..20128043aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -1,15 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.guide; -import java.util.Optional; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; @@ -17,13 +7,20 @@ import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; +import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * This is a static utility class that provides convenient access to the methods * of {@link SlimefunGuideImplementation} that abstracts away the actual implementation. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunGuideImplementation * @see SurvivalSlimefunGuide * @@ -82,7 +79,8 @@ public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode mode, i } @ParametersAreNonnullByDefault - public static void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, SlimefunGuideMode mode, int selectedPage) { + public static void openItemGroup( + PlayerProfile profile, ItemGroup itemGroup, SlimefunGuideMode mode, int selectedPage) { Slimefun.getRegistry().getSlimefunGuide(mode).openItemGroup(profile, itemGroup, selectedPage); } @@ -94,20 +92,24 @@ public static void openSearch(PlayerProfile profile, String input, SlimefunGuide @ParametersAreNonnullByDefault public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) { - Slimefun.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory); + Slimefun.getRegistry() + .getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE) + .displayItem(profile, item, 0, addToHistory); } @ParametersAreNonnullByDefault public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) { - Slimefun.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory); + Slimefun.getRegistry() + .getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE) + .displayItem(profile, item, addToHistory); } /** * This method checks if a given {@link ItemStack} is a {@link SlimefunGuide}. - * + * * @param item * The {@link ItemStack} to check - * + * * @return Whether this {@link ItemStack} represents a {@link SlimefunGuide} */ public static boolean isGuideItem(@Nullable ItemStack item) { @@ -116,7 +118,8 @@ public static boolean isGuideItem(@Nullable ItemStack item) { } else if (item instanceof SlimefunGuideItem) { return true; } else { - return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true); + return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) + || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java index eb7e3f8511..532f886e2e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java @@ -20,7 +20,7 @@ * to the {@link SlimefunGuide}. * * @author TheBusyBiscuit - * + * * @see SlimefunGuideMode * @see SurvivalSlimefunGuide * @@ -74,9 +74,9 @@ default void unlockItem(Player p, SlimefunItem sfitem, Consumer callback p.setLevel(p.getLevel() - research.getLevelCost()); } - boolean skipLearningAnimation = Slimefun.getConfigManager().isLearningAnimationDisabled() || !SlimefunGuideSettings.hasLearningAnimationEnabled(p); + boolean skipLearningAnimation = Slimefun.getConfigManager().isLearningAnimationDisabled() + || !SlimefunGuideSettings.hasLearningAnimationEnabled(p); research.unlock(p, skipLearningAnimation, callback); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java index 59597bd66a..e4ef843624 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideMode.java @@ -1,15 +1,14 @@ package io.github.thebusybiscuit.slimefun4.core.guide; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - import javax.annotation.Nonnull; /** * This enum holds the different designs a {@link SlimefunGuide} can have. * Each constant corresponds to a {@link SlimefunGuideImplementation}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunGuide * @see SlimefunGuideImplementation * @@ -41,5 +40,4 @@ public enum SlimefunGuideMode { public @Nonnull String getDisplayName() { return displayName; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java index 93e8d89a35..fc117a1905 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/ContributorsMenu.java @@ -1,15 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.guide.options; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.SkullMeta; - import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.common.CommonPatterns; import io.github.bakedlibs.dough.items.CustomItemStack; @@ -19,12 +9,19 @@ import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - +import java.util.ArrayList; +import java.util.Comparator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.SkullMeta; /** * This menu shows a list of every {@link Contributor} to this project. - * + * * @author TheBusyBiscuit * */ @@ -40,13 +37,17 @@ public static void open(Player p, int page) { ChestMenuUtils.drawBackground(menu, 0, 2, 3, 4, 5, 6, 7, 8, 45, 47, 48, 49, 50, 51, 53); - menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")))); + menu.addItem( + 1, + new CustomItemStack(ChestMenuUtils.getBackButton( + p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")))); menu.addMenuClickHandler(1, (pl, slot, item, action) -> { SlimefunGuideSettings.openSettings(pl, p.getInventory().getItemInMainHand()); return false; }); - List contributors = new ArrayList<>(Slimefun.getGitHubService().getContributors().values()); + List contributors = + new ArrayList<>(Slimefun.getGitHubService().getContributors().values()); contributors.sort(Comparator.comparingInt(Contributor::getPosition)); for (int i = page * 36; i < contributors.size() && i < (page + 1) * 36; i++) { @@ -108,7 +109,8 @@ private static ItemStack getContributorHead(Player p, Contributor contributor) { } if (entry.getValue() > 0) { - String commits = Slimefun.getLocalization().getMessage(p, "guide.credits." + (entry.getValue() > 1 ? "commits" : "commit")); + String commits = Slimefun.getLocalization() + .getMessage(p, "guide.credits." + (entry.getValue() > 1 ? "commits" : "commit")); info += " &7(" + entry.getValue() + ' ' + commits + ')'; } @@ -118,12 +120,12 @@ private static ItemStack getContributorHead(Player p, Contributor contributor) { if (contributor.getProfile() != null) { lore.add(""); - lore.add(ChatColors.color("&7\u21E8 &e") + Slimefun.getLocalization().getMessage(p, "guide.credits.profile-link")); + lore.add(ChatColors.color("&7\u21E8 &e") + + Slimefun.getLocalization().getMessage(p, "guide.credits.profile-link")); } meta.setLore(lore); skull.setItemMeta(meta); return skull; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java index 5bf6775fb9..53fd042e49 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java @@ -29,7 +29,15 @@ public Optional getDisplayItem(Player p, ItemStack guide) { if (cfgManager.isResearchingEnabled() && cfgManager.isResearchFireworkEnabled()) { boolean enabled = getSelectedOption(p, guide).orElse(true); - ItemStack item = new CustomItemStack(Material.FIREWORK_ROCKET, "&b烟花特效: &" + (enabled ? "a启用" : "4禁用"), "", "&7你现在可以选择是否", "&7在解锁一个新物品的时候", "&7展示烟花特效.", "", "&7\u21E8 &e点击 " + (enabled ? "禁用" : "启用") + " 烟花特效"); + ItemStack item = new CustomItemStack( + Material.FIREWORK_ROCKET, + "&b烟花特效: &" + (enabled ? "a启用" : "4禁用"), + "", + "&7你现在可以选择是否", + "&7在解锁一个新物品的时候", + "&7展示烟花特效.", + "", + "&7\u21E8 &e点击 " + (enabled ? "禁用" : "启用") + " 烟花特效"); return Optional.of(item); } else { return Optional.empty(); @@ -53,5 +61,4 @@ public Optional getSelectedOption(Player p, ItemStack guide) { public void setSelectedOption(Player p, ItemStack guide, Boolean value) { PersistentDataAPI.setByte(p, getKey(), value.booleanValue() ? (byte) 1 : (byte) 0); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java index cd9e331278..5ce62204d7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideModeOption.java @@ -1,12 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.guide.options; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import java.util.ArrayList; import java.util.List; import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -14,13 +17,6 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - class GuideModeOption implements SlimefunGuideOption { @Nonnull @@ -113,5 +109,4 @@ public Optional getSelectedOption(@Nonnull Player p, @Nonnull public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value) { guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta()); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java index f172eb950a..06ece07849 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/LearningAnimationOption.java @@ -44,9 +44,12 @@ public Optional getDisplayItem(@Nonnull Player p, @Nonnull ItemStack } else { boolean enabled = getSelectedOption(p, guide).orElse(true); String optionState = enabled ? "enabled" : "disabled"; - List lore = Slimefun.getLocalization().getMessages(p, "guide.options.learning-animation." + optionState + ".text"); + List lore = Slimefun.getLocalization() + .getMessages(p, "guide.options.learning-animation." + optionState + ".text"); lore.add(""); - lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.learning-animation." + optionState + ".click")); + lore.add("&7\u21E8 " + + Slimefun.getLocalization() + .getMessage(p, "guide.options.learning-animation." + optionState + ".click")); ItemStack item = new CustomItemStack(enabled ? Material.MAP : Material.PAPER, lore); return Optional.of(item); @@ -70,5 +73,4 @@ public Optional getSelectedOption(@Nonnull Player p, @Nonnull ItemStack public void setSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull Boolean value) { PersistentDataAPI.setByte(p, getKey(), (byte) (value.booleanValue() ? 1 : 0)); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java index 925943eb90..62cc39fb6a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java @@ -1,14 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.guide.options; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import org.bukkit.ChatColor; -import org.bukkit.NamespacedKey; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; @@ -20,8 +11,14 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; +import org.bukkit.ChatColor; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; class PlayerLanguageOption implements SlimefunGuideOption { @@ -39,17 +36,37 @@ public NamespacedKey getKey() { public Optional getDisplayItem(Player p, ItemStack guide) { if (Slimefun.getLocalization().isEnabled()) { Language language = Slimefun.getLocalization().getLanguage(p); - String languageName = language.isDefault() ? (Slimefun.getLocalization().getMessage(p, "languages.default") + ChatColor.DARK_GRAY + " (" + language.getName(p) + ")") : Slimefun.getLocalization().getMessage(p, "languages." + language.getId()); + String languageName = language.isDefault() + ? (Slimefun.getLocalization().getMessage(p, "languages.default") + + ChatColor.DARK_GRAY + + " (" + + language.getName(p) + + ")") + : Slimefun.getLocalization().getMessage(p, "languages." + language.getId()); List lore = new ArrayList<>(); lore.add(""); lore.add("&e&o" + Slimefun.getLocalization().getMessage(p, "guide.work-in-progress")); lore.add(""); - lore.addAll(Slimefun.getLocalization().getMessages(p, "guide.languages.description", msg -> msg.replace("%contributors%", String.valueOf(Slimefun.getGitHubService().getContributors().size())))); + lore.addAll(Slimefun.getLocalization() + .getMessages( + p, + "guide.languages.description", + msg -> msg.replace( + "%contributors%", + String.valueOf(Slimefun.getGitHubService() + .getContributors() + .size())))); lore.add(""); lore.add("&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.change")); - ItemStack item = new CustomItemStack(language.getItem(), "&7" + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0])); + ItemStack item = new CustomItemStack( + language.getItem(), + "&7" + + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language") + + " &a" + + languageName, + lore.toArray(new String[0])); return Optional.of(item); } else { return Optional.empty(); @@ -83,16 +100,29 @@ private void openLanguageSelection(Player p, ItemStack guide) { for (int i = 0; i < 9; i++) { if (i == 1) { - menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")), (pl, slot, item, action) -> { - SlimefunGuideSettings.openSettings(pl, guide); - return false; - }); + menu.addItem( + 1, + ChestMenuUtils.getBackButton( + p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")), + (pl, slot, item, action) -> { + SlimefunGuideSettings.openSettings(pl, guide); + return false; + }); } else if (i == 7) { - menu.addItem(7, new CustomItemStack(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> { - ChatUtils.sendURL(pl, "https://slimefun-wiki.guizhanss.cn/Translating-Slimefun"); - pl.closeInventory(); - return false; - }); + menu.addItem( + 7, + new CustomItemStack( + SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), + "", + "&7\u21E8 &e" + + Slimefun.getLocalization() + .getMessage(p, "guide.languages.translations.lore")), + (pl, slot, item, action) -> { + ChatUtils.sendURL(pl, "https://slimefun-wiki.guizhanss.cn/Translating-Slimefun"); + pl.closeInventory(); + return false; + }); } else { menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } @@ -101,34 +131,64 @@ private void openLanguageSelection(Player p, ItemStack guide) { Language defaultLanguage = Slimefun.getLocalization().getDefaultLanguage(); String defaultLanguageString = Slimefun.getLocalization().getMessage(p, "languages.default"); - menu.addItem(9, new CustomItemStack(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> { - Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage)); - setSelectedOption(pl, guide, null); + menu.addItem( + 9, + new CustomItemStack( + defaultLanguage.getItem(), + ChatColor.GRAY + + defaultLanguageString + + ChatColor.DARK_GRAY + + " (" + + defaultLanguage.getName(p) + + ")", + "", + "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), + (pl, i, item, action) -> { + Slimefun.instance() + .getServer() + .getPluginManager() + .callEvent(new PlayerLanguageChangeEvent( + pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage)); + setSelectedOption(pl, guide, null); + + Slimefun.getLocalization() + .sendMessage( + pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString)); - Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString)); - - SlimefunGuideSettings.openSettings(pl, guide); - return false; - }); + SlimefunGuideSettings.openSettings(pl, guide); + return false; + }); int slot = 10; for (Language language : Slimefun.getLocalization().getLanguages()) { - menu.addItem(slot, new CustomItemStack(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> { - Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), language)); - setSelectedOption(pl, guide, language.getId()); - - String name = language.getName(pl); - Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name)); - - SlimefunGuideSettings.openSettings(pl, guide); - return false; - }); + menu.addItem( + slot, + new CustomItemStack( + language.getItem(), + ChatColor.GREEN + language.getName(p), + "&b" + language.getTranslationProgress() + '%', + "", + "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), + (pl, i, item, action) -> { + Slimefun.instance() + .getServer() + .getPluginManager() + .callEvent(new PlayerLanguageChangeEvent( + pl, Slimefun.getLocalization().getLanguage(pl), language)); + setSelectedOption(pl, guide, language.getId()); + + String name = language.getName(pl); + Slimefun.getLocalization() + .sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name)); + + SlimefunGuideSettings.openSettings(pl, guide); + return false; + }); slot++; } menu.open(p); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java index 1caeb02826..82100c96ff 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideOption.java @@ -1,19 +1,16 @@ package io.github.thebusybiscuit.slimefun4.core.guide.options; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; import java.util.Optional; - import javax.annotation.Nonnull; - import org.bukkit.Keyed; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; - /** * This interface represents an option in the {@link SlimefunGuide}. - * + * * @author TheBusyBiscuit * * @param @@ -23,7 +20,7 @@ public interface SlimefunGuideOption extends Keyed { /** * This returns the {@link SlimefunAddon} which added this {@link SlimefunGuideOption}. - * + * * @return The registering {@link SlimefunAddon} */ @Nonnull @@ -36,5 +33,4 @@ public interface SlimefunGuideOption extends Keyed { Optional getSelectedOption(Player p, ItemStack guide); void setSelectedOption(Player p, ItemStack guide, T value); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java index df330df332..a1e72830d0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java @@ -1,18 +1,5 @@ package io.github.thebusybiscuit.slimefun4.core.guide.options; -import java.util.ArrayList; -import java.util.List; -import java.util.Optional; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.api.researches.Research; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; @@ -26,23 +13,35 @@ import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; /** * This static utility class offers various methods that provide access to the * Settings menu of our {@link SlimefunGuide}. - * + * * This menu is used to allow a {@link Player} to change things such as the {@link Language}. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunGuide * */ public final class SlimefunGuideSettings { - private static final int[] BACKGROUND_SLOTS = { 1, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 50, 52, 53 }; + private static final int[] BACKGROUND_SLOTS = { + 1, 3, 5, 7, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 26, 27, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, + 50, 52, 53 + }; private static final List> options = new ArrayList<>(); static { @@ -78,11 +77,13 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { LocalizationService locale = Slimefun.getLocalization(); // @formatter:off - menu.addItem(0, new CustomItemStack(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE), - "&e\u21E6 " + locale.getMessage(p, "guide.back.title"), - "", - "&7" + locale.getMessage(p, "guide.back.guide") - )); + menu.addItem( + 0, + new CustomItemStack( + SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE), + "&e\u21E6 " + locale.getMessage(p, "guide.back.title"), + "", + "&7" + locale.getMessage(p, "guide.back.guide"))); // @formatter:on menu.addMenuClickHandler(0, (pl, slot, item, action) -> { @@ -94,15 +95,22 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { List contributorsLore = new ArrayList<>(); contributorsLore.add(""); - contributorsLore.addAll(locale.getMessages(p, "guide.credits.description", msg -> msg.replace("%contributors%", String.valueOf(github.getContributors().size())))); + contributorsLore.addAll(locale.getMessages( + p, + "guide.credits.description", + msg -> msg.replace( + "%contributors%", + String.valueOf(github.getContributors().size())))); contributorsLore.add(""); contributorsLore.add("&7\u21E8 &e" + locale.getMessage(p, "guide.credits.open")); // @formatter:off - menu.addItem(2, new CustomItemStack(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"), - "&c" + locale.getMessage(p, "guide.title.credits"), - contributorsLore.toArray(new String[0]) - )); + menu.addItem( + 2, + new CustomItemStack( + SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"), + "&c" + locale.getMessage(p, "guide.title.credits"), + contributorsLore.toArray(new String[0]))); // @formatter:on menu.addMenuClickHandler(2, (pl, slot, action, item) -> { @@ -111,7 +119,10 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(4, new CustomItemStack(Material.WRITABLE_BOOK, + menu.addItem( + 4, + new CustomItemStack( + Material.WRITABLE_BOOK, ChatColor.GREEN + locale.getMessage(p, "guide.title.versions"), "&7&o" + locale.getMessage(p, "guide.tooltips.versions-notice"), "", @@ -123,24 +134,26 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { "", "&fMinecraft: &a" + Bukkit.getBukkitVersion(), "&fSlimefun: &a" + Slimefun.getVersion()), - ChestMenuUtils.getEmptyClickHandler() - ); + ChestMenuUtils.getEmptyClickHandler()); // @formatter:on // @formatter:off - menu.addItem(6, new CustomItemStack(Material.COMPARATOR, - "&e" + locale.getMessage(p, "guide.title.source"), - "", "&7最近活动于: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " 前", - "&7Forks: &e" + github.getForks(), - "&7Stars: &e" + github.getStars(), - "", - "&7&oSlimefun 4 是一个由社区参与的项目,", - "&7&o源代码可以在 GitHub 上找到", - "&7&o如果你想让这个项目持续下去", - "&7&o你可以考虑对项目做出贡献", - "", - "&7\u21E8 &e点击前往汉化版 GitHub 仓库" - )); + menu.addItem( + 6, + new CustomItemStack( + Material.COMPARATOR, + "&e" + locale.getMessage(p, "guide.title.source"), + "", + "&7最近活动于: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " 前", + "&7Forks: &e" + github.getForks(), + "&7Stars: &e" + github.getStars(), + "", + "&7&oSlimefun 4 是一个由社区参与的项目,", + "&7&o源代码可以在 GitHub 上找到", + "&7&o如果你想让这个项目持续下去", + "&7&o你可以考虑对项目做出贡献", + "", + "&7\u21E8 &e点击前往汉化版 GitHub 仓库")); // @formatter:on menu.addMenuClickHandler(6, (pl, slot, item, action) -> { @@ -150,15 +163,18 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, - "&3" + locale.getMessage(p, "guide.title.wiki"), - "", "&7你需要对物品或机器方面的帮助吗?", - "&7你不知道要干什么?", - "&7查看我们的由社区维护的维基", - "&7并考虑成为一名编辑者!", - "", - "&7\u21E8 &e点击前往非官方中文 Wiki" - )); + menu.addItem( + 8, + new CustomItemStack( + Material.KNOWLEDGE_BOOK, + "&3" + locale.getMessage(p, "guide.title.wiki"), + "", + "&7你需要对物品或机器方面的帮助吗?", + "&7你不知道要干什么?", + "&7查看我们的由社区维护的维基", + "&7并考虑成为一名编辑者!", + "", + "&7\u21E8 &e点击前往非官方中文 Wiki")); // @formatter:on menu.addMenuClickHandler(8, (pl, slot, item, action) -> { @@ -168,17 +184,19 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { }); // @formatter:off - menu.addItem(47, new CustomItemStack(Material.BOOKSHELF, - "&3" + locale.getMessage(p, "guide.title.addons"), - "", - "&7Slimefun 是一个大型项目,但附属插件的存在", - "&7能让 Slimefun 真正的发光发亮", - "&7看一看它们,也许你要寻找的附属插件就在那里!", - "", - "&7该服务器已安装附属插件: &b" + Slimefun.getInstalledAddons().size(), - "", - "&7\u21E8 &e点击查看 Slimefun4 可用的附属插件" - )); + menu.addItem( + 47, + new CustomItemStack( + Material.BOOKSHELF, + "&3" + locale.getMessage(p, "guide.title.addons"), + "", + "&7Slimefun 是一个大型项目,但附属插件的存在", + "&7能让 Slimefun 真正的发光发亮", + "&7看一看它们,也许你要寻找的附属插件就在那里!", + "", + "&7该服务器已安装附属插件: &b" + Slimefun.getInstalledAddons().size(), + "", + "&7\u21E8 &e点击查看 Slimefun4 可用的附属插件")); // @formatter:on menu.addMenuClickHandler(47, (pl, slot, item, action) -> { @@ -189,16 +207,18 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { if (Slimefun.getUpdater().getBranch().isOfficial()) { // @formatter:off - menu.addItem(49, new CustomItemStack(Material.REDSTONE_TORCH, - "&4" + locale.getMessage(p, "guide.title.bugs"), - "", - "&7&oBug reports have to be made in English!", - "", - "&7Open Issues: &a" + github.getOpenIssues(), - "&7Pending Pull Requests: &a" + github.getPendingPullRequests(), - "", - "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker" - )); + menu.addItem( + 49, + new CustomItemStack( + Material.REDSTONE_TORCH, + "&4" + locale.getMessage(p, "guide.title.bugs"), + "", + "&7&oBug reports have to be made in English!", + "", + "&7Open Issues: &a" + github.getOpenIssues(), + "&7Pending Pull Requests: &a" + github.getPendingPullRequests(), + "", + "&7\u21E8 &eClick to go to the Slimefun4 Bug Tracker")); // @formatter:on menu.addMenuClickHandler(49, (pl, slot, item, action) -> { @@ -210,10 +230,14 @@ private static void addHeader(Player p, ChestMenu menu, ItemStack guide) { menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(51, new CustomItemStack(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> { - // Add something here - return false; - }); + menu.addItem( + 51, + new CustomItemStack( + Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), + (pl, slot, item, action) -> { + // Add something here + return false; + }); } @ParametersAreNonnullByDefault @@ -239,10 +263,10 @@ private static void addConfigurableOptions(Player p, ChestMenu menu, ItemStack g * This method checks if the given {@link Player} has enabled the {@link FireworksOption} * in their {@link SlimefunGuide}. * If they enabled this setting, they will see fireworks when they unlock a {@link Research}. - * + * * @param p * The {@link Player} - * + * * @return Whether this {@link Player} wants to see fireworks when unlocking a {@link Research} */ public static boolean hasFireworksEnabled(@Nonnull Player p) { @@ -277,11 +301,12 @@ public static boolean hasLearningAnimationEnabled(@Nonnull Player p) { * Type of the {@link SlimefunGuideOption} * @param * Type of the {@link SlimefunGuideOption} value - * + * * @return The value of given {@link SlimefunGuideOption} */ @Nonnull - private static , V> V getOptionValue(@Nonnull Player p, @Nonnull Class optionsClass, @Nonnull V defaultValue) { + private static , V> V getOptionValue( + @Nonnull Player p, @Nonnull Class optionsClass, @Nonnull V defaultValue) { for (SlimefunGuideOption option : options) { if (optionsClass.isInstance(option)) { T o = optionsClass.cast(option); @@ -292,5 +317,4 @@ private static , V> V getOptionValue(@Nonnull P return defaultValue; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java index 14f426c5c6..994c6bde17 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/package-info.java @@ -3,4 +3,4 @@ * well as the interface {@link io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideOption} for adding * your own options */ -package io.github.thebusybiscuit.slimefun4.core.guide.options; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.guide.options; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java index 0d47912f05..4c1d020299 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/package-info.java @@ -2,4 +2,4 @@ * This package contains the core system for the {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide}. * Note that you can find the individual implementations of the guide, in the implementation package */ -package io.github.thebusybiscuit.slimefun4.core.guide; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.guide; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java index 7bd704a509..60affc23b5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockBreakHandler.java @@ -1,29 +1,26 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; +import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; +import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; import java.util.List; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; - /** * The {@link BlockBreakHandler} is called when a {@link Block} is broken * which holds a {@link SlimefunItem}. * The {@link BlockBreakHandler} provides three methods for this, one for block breaking * caused by a {@link Player}, one for a {@link MinerAndroid} and one method for a {@link Block} * being destroyed by an explosion. - * + * * @author TheBusyBiscuit - * + * * @see BlockPlaceHandler * */ @@ -41,7 +38,7 @@ public abstract class BlockBreakHandler implements ItemHandler { /** * This constructs a new {@link BlockBreakHandler}. - * + * * @param allowAndroids * Whether a {@link MinerAndroid} is allowed to break blocks of this type * @param allowExplosions @@ -67,7 +64,7 @@ public void onAndroidBreak(AndroidMineEvent e) { /** * This returns whether an explosion is able to break the given {@link Block}. - * + * * @param b * The {@link Block} * @return Whether explosions can destroy this {@link Block} @@ -83,10 +80,10 @@ public boolean isExplosionAllowed(@Nonnull Block b) { /** * This returns whether a {@link MinerAndroid} is allowed to break * the given {@link Block}. - * + * * @param b * The {@link Block} - * + * * @return Whether androids can break the given {@link Block} */ public boolean isAndroidAllowed(@Nonnull Block b) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java index 8f10c0fa97..8884884c55 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockDispenseHandler.java @@ -1,29 +1,27 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; -import java.util.Optional; - -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.block.Dispenser; -import org.bukkit.event.block.BlockDispenseEvent; - import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; +import java.util.Optional; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.block.Dispenser; +import org.bukkit.event.block.BlockDispenseEvent; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to * is a {@link Dispenser} and was triggered. - * + * * This {@link ItemHandler} is used for the {@link BlockPlacer}. - * + * * @author TheBusyBiscuit * * @see ItemHandler * @see BlockPlacer - * + * */ @FunctionalInterface public interface BlockDispenseHandler extends ItemHandler { @@ -31,7 +29,10 @@ public interface BlockDispenseHandler extends ItemHandler { @Override default Optional validate(SlimefunItem item) { if (item instanceof NotPlaceable || item.getItem().getType() != Material.DISPENSER) { - return Optional.of(new IncompatibleItemHandlerException("Only dispensers that are not marked as 'NotPlaceable' can have a BlockDispenseHandler.", item, this)); + return Optional.of(new IncompatibleItemHandlerException( + "Only dispensers that are not marked as 'NotPlaceable' can have a" + " BlockDispenseHandler.", + item, + this)); } return Optional.empty(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java index e2cb771bfc..b660ea7e47 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockPlaceHandler.java @@ -1,21 +1,19 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; -import javax.annotation.Nonnull; - -import org.bukkit.block.Block; -import org.bukkit.entity.Player; -import org.bukkit.event.block.BlockPlaceEvent; - import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer; +import javax.annotation.Nonnull; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; +import org.bukkit.event.block.BlockPlaceEvent; /** * This {@link ItemHandler} is called whenever a {@link Block} was placed. * This only listens to any {@link Block} of the same {@link SlimefunItem} this is assigned * to. - * + * * @author TheBusyBiscuit * */ @@ -29,7 +27,7 @@ protected BlockPlaceHandler(boolean allowBlockPlacers) { /** * This method is called whenever a {@link Player} placed this {@link Block}. - * + * * @param e * The corresponding {@link BlockPlaceEvent} */ @@ -40,7 +38,7 @@ protected BlockPlaceHandler(boolean allowBlockPlacers) { * You cannot cancel the {@link BlockPlacerPlaceEvent} from within this method! * Override the method {@link #isBlockPlacerAllowed()} instead if you want to disallow the * {@link BlockPlacer} from placing this {@link Block}. - * + * * @param e * The corresponding {@link BlockPlacerPlaceEvent} */ @@ -50,7 +48,7 @@ public void onBlockPlacerPlace(@Nonnull BlockPlacerPlaceEvent e) { /** * This returns whether the {@link BlockPlacer} is allowed to place a {@link Block} of this type. - * + * * @return Whether a {@link BlockPlacer} is allowed to place this */ public boolean isBlockPlacerAllowed() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java index 7dde59c45e..a9401c6410 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BlockUseHandler.java @@ -5,7 +5,6 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; - import java.util.Optional; @FunctionalInterface @@ -16,7 +15,8 @@ public interface BlockUseHandler extends ItemHandler { @Override default Optional validate(SlimefunItem item) { if (item instanceof NotPlaceable || !item.getItem().getType().isBlock()) { - return Optional.of(new IncompatibleItemHandlerException("Only blocks that are not marked as 'NotPlaceable' can have a BlockUseHandler.", item, this)); + return Optional.of(new IncompatibleItemHandlerException( + "Only blocks that are not marked as 'NotPlaceable' can have a BlockUseHandler.", item, this)); } return Optional.empty(); @@ -26,5 +26,4 @@ default Optional validate(SlimefunItem item) { default Class getIdentifier() { return BlockUseHandler.class; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java index f2c5aa7df0..fb7a65d995 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/BowShootHandler.java @@ -1,25 +1,23 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; -import java.util.Optional; - -import org.bukkit.Material; -import org.bukkit.entity.LivingEntity; -import org.bukkit.event.entity.EntityDamageByEntityEvent; - import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.weapons.SlimefunBow; +import java.util.Optional; +import org.bukkit.Material; +import org.bukkit.entity.LivingEntity; +import org.bukkit.event.entity.EntityDamageByEntityEvent; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to * is a {@link SlimefunBow} and an Arrow fired from this bow hit a {@link LivingEntity}. - * + * * @author TheBusyBiscuit * * @see ItemHandler * @see SlimefunBow - * + * */ @FunctionalInterface public interface BowShootHandler extends ItemHandler { @@ -29,7 +27,8 @@ public interface BowShootHandler extends ItemHandler { @Override default Optional validate(SlimefunItem item) { if (item.getItem().getType() != Material.BOW) { - return Optional.of(new IncompatibleItemHandlerException("Only bows can have a BowShootHandler.", item, this)); + return Optional.of( + new IncompatibleItemHandlerException("Only bows can have a BowShootHandler.", item, this)); } return Optional.empty(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java index 1091d3a335..67c6022330 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityInteractHandler.java @@ -1,5 +1,9 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; +import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerInteractAtEntityEvent; @@ -7,11 +11,6 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.EntityInteractionListener; - /** * This is triggered when a {@link Player} interacts with an {@link Entity}. * @@ -42,4 +41,4 @@ public interface EntityInteractHandler extends ItemHandler { default Class getIdentifier() { return EntityInteractHandler.class; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java index 21ec3c0179..2437566dfc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/EntityKillHandler.java @@ -1,24 +1,23 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; +import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; - /** * If this {@link ItemHandler} is added to a {@link SlimefunItem} it will listen * for any {@link EntityDeathEvent} that was triggered by a {@link Player} using * the {@link SlimefunItem} this {@link EntityKillHandler} was linked to. - * + * * @author TheBusyBiscuit * * @see ItemHandler * @see SimpleSlimefunItem - * + * */ @FunctionalInterface public interface EntityKillHandler extends ItemHandler { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java index 3716eff948..1d0051e2d1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/GlobalItemHandler.java @@ -1,10 +1,9 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; -import org.bukkit.event.Event; -import org.bukkit.event.Listener; - import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import org.bukkit.event.Event; +import org.bukkit.event.Listener; /** * A {@link GlobalItemHandler} is a special type of {@link ItemHandler} @@ -16,6 +15,4 @@ * @see ItemDropHandler * */ -public interface GlobalItemHandler extends ItemHandler { - -} \ No newline at end of file +public interface GlobalItemHandler extends ItemHandler {} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java index 69a5d44089..1648e8072d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemConsumptionHandler.java @@ -1,29 +1,28 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; -import org.bukkit.entity.Player; -import org.bukkit.event.player.PlayerItemConsumeEvent; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie; import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie; +import org.bukkit.entity.Player; +import org.bukkit.event.player.PlayerItemConsumeEvent; +import org.bukkit.inventory.ItemStack; /** * This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to * has been consumed. - * + * * This {@link ItemHandler} only works for food or potions. - * + * * @author TheBusyBiscuit * * @see ItemHandler * @see SimpleSlimefunItem - * + * * @see FortuneCookie * @see DietCookie - * + * */ @FunctionalInterface public interface ItemConsumptionHandler extends ItemHandler { @@ -31,7 +30,7 @@ public interface ItemConsumptionHandler extends ItemHandler { /** * This method gets fired whenever a {@link PlayerItemConsumeEvent} involving this * {@link SlimefunItem} has been triggered. - * + * * @param e * The {@link PlayerItemConsumeEvent} that was fired * @param p @@ -45,5 +44,4 @@ public interface ItemConsumptionHandler extends ItemHandler { default Class getIdentifier() { return ItemConsumptionHandler.class; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java index a0e6efbb6a..2e30ab3d54 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemDropHandler.java @@ -1,17 +1,15 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; +import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerDropItemEvent; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; - /** * The {@link ItemDropHandler} is a {@link GlobalItemHandler} which listens to * an {@link Item} being dropped. - * + * * @author Linox * @author TheBusyBiscuit * diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java index 987699bcf1..21e09b1132 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ItemUseHandler.java @@ -22,5 +22,4 @@ public interface ItemUseHandler extends ItemHandler { default Class getIdentifier() { return ItemUseHandler.class; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java index 0ae90600bd..5c6936bed2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/MultiBlockInteractionHandler.java @@ -1,24 +1,22 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; -import java.util.Optional; - -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException; import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; +import java.util.Optional; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; /** * This {@link ItemHandler} is called whenever a {@link Player} interacts with * this {@link MultiBlock}. * Note that this {@link MultiBlockInteractionHandler} should be assigned to * a class that inherits from {@link MultiBlockMachine}. - * + * * @author TheBusyBiscuit - * + * * @see ItemHandler * @see MultiBlock * @see MultiBlockMachine @@ -32,7 +30,8 @@ public interface MultiBlockInteractionHandler extends ItemHandler { @Override default Optional validate(SlimefunItem item) { if (!(item instanceof MultiBlockMachine)) { - return Optional.of(new IncompatibleItemHandlerException("Only classes inheriting 'MultiBlockMachine' can have a MultiBlockInteractionHandler", item, this)); + return Optional.of(new IncompatibleItemHandlerException( + "Only classes inheriting 'MultiBlockMachine' can have a MultiBlockInteractionHandler", item, this)); } return Optional.empty(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java index 82572a8bc6..bd84a5a514 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/RainbowTickHandler.java @@ -7,6 +7,9 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.RainbowBlock; import io.github.thebusybiscuit.slimefun4.utils.ColoredMaterial; +import java.util.Arrays; +import java.util.List; +import javax.annotation.Nonnull; import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; import org.apache.commons.lang.Validate; import org.bukkit.Material; @@ -15,17 +18,13 @@ import org.bukkit.block.data.BlockData; import org.bukkit.block.data.type.GlassPane; -import javax.annotation.Nonnull; -import java.util.Arrays; -import java.util.List; - /** * This is a {@link BlockTicker} that is exclusively used for Rainbow blocks. * On every tick it cycles through the {@link LoopIterator} and chooses the next {@link Material} * and sets itself to that. - * + * * @author TheBusyBiscuit - * + * * @see RainbowBlock * */ @@ -60,10 +59,10 @@ public RainbowTickHandler(@Nonnull ColoredMaterial material) { * that would result in a {@link GlassPane} {@link BlockData}. * This is done to save performance, so we don't have to validate {@link BlockData} at * runtime. - * + * * @param materials * The {@link Material} Array to check - * + * * @return Whether the array contained any {@link GlassPane} materials */ private boolean containsGlassPanes(@Nonnull List materials) { @@ -74,10 +73,10 @@ private boolean containsGlassPanes(@Nonnull List materials) { for (Material type : materials) { /* - This BlockData is purely virtual and only created on startup, it should have - no impact on performance, in fact it should save performance as it preloads - the data but also saves heavy calls for other Materials - */ + This BlockData is purely virtual and only created on startup, it should have + no impact on performance, in fact it should save performance as it preloads + the data but also saves heavy calls for other Materials + */ if (type.createBlockData() instanceof GlassPane) { return true; } @@ -90,9 +89,9 @@ private boolean containsGlassPanes(@Nonnull List materials) { public void tick(Block b, SlimefunItem item, SlimefunBlockData data) { if (b.getType().isAir()) { /* - The block was broken, setting the Material now would result in a - duplication glitch - */ + The block was broken, setting the Material now would result in a + duplication glitch + */ return; } @@ -127,5 +126,4 @@ public void uniqueTick() { public boolean isSynchronized() { return true; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java index 579b5f5749..646c08325c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/ToolUseHandler.java @@ -1,19 +1,17 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; +import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.List; - import org.bukkit.block.Block; import org.bukkit.enchantments.Enchantment; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This {@link ItemHandler} is called when a {@link Block} is broken with a {@link SlimefunItem} * as its tool. - * + * * @author TheBusyBiscuit * * @see BlockBreakHandler @@ -25,7 +23,7 @@ public interface ToolUseHandler extends ItemHandler { /** * This method is called whenever a {@link BlockBreakEvent} was fired when using this * {@link SlimefunItem} to break a {@link Block}. - * + * * @param e * The {@link BlockBreakEvent} * @param tool @@ -34,7 +32,7 @@ public interface ToolUseHandler extends ItemHandler { * The amount of bonus drops to be expected from the fortune {@link Enchantment}. * @param drops * The dropped items - * + * */ void onToolUse(BlockBreakEvent e, ItemStack tool, int fortune, List drops); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java index 81c40c69e5..30ce24818a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/WeaponUseHandler.java @@ -1,15 +1,13 @@ package io.github.thebusybiscuit.slimefun4.core.handlers; +import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import javax.annotation.Nonnull; - import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This is triggered when a {@link Player} attacks an {@link Entity}. * @@ -35,5 +33,4 @@ public interface WeaponUseHandler extends ItemHandler { default Class getIdentifier() { return WeaponUseHandler.class; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java index d3c439ec1e..f20f02802b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/handlers/package-info.java @@ -2,4 +2,4 @@ * This package contains all variations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemHandler} that * can be assigned to a {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} */ -package io.github.thebusybiscuit.slimefun4.core.handlers; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.handlers; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java index 2e80f4bebd..55da36772d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineOperation.java @@ -56,5 +56,4 @@ default int getRemainingTicks() { default boolean isFinished() { return getRemainingTicks() <= 0; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java index 2294acccd5..d503fac907 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/MachineProcessor.java @@ -1,11 +1,14 @@ package io.github.thebusybiscuit.slimefun4.core.machines; +import io.github.bakedlibs.dough.blocks.BlockPosition; +import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineOperationFinishEvent; +import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; +import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -13,13 +16,6 @@ import org.bukkit.event.Event; import org.bukkit.inventory.ItemStack; -import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.api.events.AsyncMachineOperationFinishEvent; -import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; -import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; - -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; - /** * A {@link MachineProcessor} manages different {@link MachineOperation}s and handles * their progress. @@ -67,8 +63,7 @@ public MachineProcessHolder getOwner() { * * @return The progress bar icon or null */ - @Nullable - public ItemStack getProgressBar() { + @Nullable public ItemStack getProgressBar() { return progressBar; } @@ -145,8 +140,7 @@ public boolean startOperation(@Nonnull BlockPosition pos, @Nonnull T operation) * * @return The current {@link MachineOperation} or null. */ - @Nullable - public T getOperation(@Nonnull Location loc) { + @Nullable public T getOperation(@Nonnull Location loc) { Validate.notNull(loc, "The location cannot be null"); return getOperation(new BlockPosition(loc)); @@ -160,8 +154,7 @@ public T getOperation(@Nonnull Location loc) { * * @return The current {@link MachineOperation} or null. */ - @Nullable - public T getOperation(@Nonnull Block b) { + @Nullable public T getOperation(@Nonnull Block b) { Validate.notNull(b, "The Block cannot be null"); return getOperation(new BlockPosition(b)); @@ -177,8 +170,7 @@ public T getOperation(@Nonnull Block b) { * * @return The current {@link MachineOperation} or null. */ - @Nullable - public T getOperation(@Nonnull BlockPosition pos) { + @Nullable public T getOperation(@Nonnull BlockPosition pos) { Validate.notNull(pos, "The BlockPosition must not be null"); return machines.get(pos); @@ -262,5 +254,4 @@ public void updateProgressBar(@Nonnull BlockMenu inv, int slot, @Nonnull T opera ChestMenuUtils.updateProgressbar(inv, slot, remainingTicks, totalTicks, getProgressBar()); } } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java index af07c73dce..3da041fda6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/machines/package-info.java @@ -3,4 +3,4 @@ * {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor} * and any {@link io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation}. */ -package io.github.thebusybiscuit.slimefun4.core.machines; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.machines; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java index 4175b20527..f0f709629d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlock.java @@ -1,31 +1,28 @@ package io.github.thebusybiscuit.slimefun4.core.multiblocks; +import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; import java.util.Arrays; import java.util.HashSet; import java.util.Objects; import java.util.Set; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.World; import org.bukkit.block.BlockFace; -import io.github.thebusybiscuit.slimefun4.api.events.MultiBlockInteractEvent; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; - /** * A {@link MultiBlock} represents a structure build in a {@link World}. * A {@link MultiBlock} is often linked to a {@link MultiBlockMachine} and is used * to recognize that machine in a {@link MultiBlockInteractEvent}. - * + * * @author TheBusyBiscuit * @author Liruxo - * + * * @see MultiBlockMachine * @see MultiBlockInteractionHandler * @see MultiBlockInteractEvent @@ -143,12 +140,13 @@ private boolean compareBlocks(Material a, @Nullable Material b) { /** * This returns whether this {@link MultiBlock} is a symmetric structure or whether * the left and right side differ. - * + * * @return Whether this {@link MultiBlock} is a symmetric structure */ public boolean isSymmetric() { return isSymmetric; } + @Override public String toString() { return "MultiBlock (" + item.getId() + ") {" + Arrays.toString(blocks) + "}"; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java index c7d9f1f369..348027af20 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java @@ -1,18 +1,28 @@ package io.github.thebusybiscuit.slimefun4.core.multiblocks; +import com.google.common.base.Preconditions; +import io.github.bakedlibs.dough.inventory.InvUtils; +import io.github.bakedlibs.dough.protection.Interaction; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; +import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; +import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - -import com.google.common.base.Preconditions; - import org.apache.commons.lang.Validate; - import org.bukkit.Material; import org.bukkit.World; import org.bukkit.block.Block; @@ -23,27 +33,12 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; -import io.github.bakedlibs.dough.inventory.InvUtils; -import io.github.bakedlibs.dough.protection.Interaction; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.ItemSpawnReason; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; -import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.MultiBlockInteractionHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.OutputChest; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - /** * A {@link MultiBlockMachine} is a {@link SlimefunItem} that is built in the {@link World}. * It holds recipes and a {@link MultiBlock} object which represents its structure. - * + * * @author TheBusyBiscuit - * + * * @see MultiBlock * */ @@ -54,7 +49,12 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace protected final MultiBlock multiblock; @ParametersAreNonnullByDefault - protected MultiBlockMachine(ItemGroup itemGroup, SlimefunItemStack item, ItemStack[] recipe, ItemStack[] machineRecipes, BlockFace trigger) { + protected MultiBlockMachine( + ItemGroup itemGroup, + SlimefunItemStack item, + ItemStack[] recipe, + ItemStack[] machineRecipes, + BlockFace trigger) { super(itemGroup, item, RecipeType.MULTIBLOCK, recipe); this.recipes = new ArrayList<>(); this.displayRecipes = new ArrayList<>(); @@ -90,7 +90,7 @@ public void addRecipe(ItemStack[] input, ItemStack output) { Validate.notNull(output, "Recipes must have an Output!"); recipes.add(input); - recipes.add(new ItemStack[] { output }); + recipes.add(new ItemStack[] {output}); } public void clearRecipe() { @@ -112,7 +112,8 @@ public void postRegister() { public void load() { super.load(); - Preconditions.checkArgument(displayRecipes.size() % 2 == 0, "This MultiBlockMachine's display recipes were illegally modified!"); + Preconditions.checkArgument( + displayRecipes.size() % 2 == 0, "This MultiBlockMachine's display recipes were illegally modified!"); for (int i = 0; i < displayRecipes.size(); i += 2) { ItemStack inputStack = displayRecipes.get(i); @@ -125,8 +126,8 @@ public void load() { SlimefunItem outputItem = SlimefunItem.getByItem(outputStack); // If the input/output is not a Slimefun item or it's not disabled then it's valid. if ((inputItem == null || !inputItem.isDisabled()) && (outputItem == null || !outputItem.isDisabled())) { - recipes.add(new ItemStack[] { inputStack }); - recipes.add(new ItemStack[] { outputStack }); + recipes.add(new ItemStack[] {inputStack}); + recipes.add(new ItemStack[] {outputStack}); } } } @@ -134,7 +135,9 @@ public void load() { protected @Nonnull MultiBlockInteractionHandler getInteractionHandler() { return (p, mb, b) -> { if (mb.equals(getMultiBlock())) { - if (canUse(p, true) && Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK)) { + if (canUse(p, true) + && Slimefun.getProtectionManager() + .hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK)) { onInteract(p, b); } @@ -152,24 +155,24 @@ public void load() { * Fallbacks to the old system of putting the adding back into the dispenser. * Optional last argument Inventory placeCheckerInv is for a {@link MultiBlockMachine} that create * a dummy inventory to check if there's a space for the adding, i.e. Enhanced crafting table - * + * * @param adding * The {@link ItemStack} that should be added * @param dispBlock * The {@link Block} of our {@link Dispenser} * @param dispInv * The {@link Inventory} of our {@link Dispenser} - * + * * @return The target {@link Inventory} */ - @ParametersAreNonnullByDefault protected @Nullable Inventory findOutputInventory(ItemStack adding, Block dispBlock, Inventory dispInv) { return findOutputInventory(adding, dispBlock, dispInv, dispInv); } @ParametersAreNonnullByDefault - protected @Nullable Inventory findOutputInventory(ItemStack product, Block dispBlock, Inventory dispInv, Inventory placeCheckerInv) { + protected @Nullable Inventory findOutputInventory( + ItemStack product, Block dispBlock, Inventory dispInv, Inventory placeCheckerInv) { Optional outputChest = OutputChest.findOutputChestFor(dispBlock, product); /* @@ -226,5 +229,4 @@ protected void handleCraftedItem(ItemStack outputItem, Block block, Inventory bl return materials.toArray(new Material[0]); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java index 23867e7f6a..5456678716 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/package-info.java @@ -2,4 +2,4 @@ * This package holds all core mechanics related to a * {@link io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock}, like that class itself. */ -package io.github.thebusybiscuit.slimefun4.core.multiblocks; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.multiblocks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java index 7757f9bd95..c079881a81 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/NetworkManager.java @@ -26,10 +26,10 @@ /** * The {@link NetworkManager} is responsible for holding all instances of {@link Network} * and providing some utility methods that would have probably been static otherwise. - * + * * @author TheBusyBiscuit * @author meiamsome - * + * * @see Network * @see NetworkListener * @@ -42,7 +42,7 @@ public class NetworkManager { /** * Fixes #3041 - * + * * We use a {@link CopyOnWriteArrayList} here to ensure thread-safety. * This {@link List} is also much more frequently read than being written to. * Therefore a {@link CopyOnWriteArrayList} should be perfect for this, even @@ -52,7 +52,7 @@ public class NetworkManager { /** * This creates a new {@link NetworkManager} with the given capacity. - * + * * @param maxStepSize * The maximum amount of nodes a {@link Network} can have * @param enableVisualizer @@ -70,7 +70,7 @@ public NetworkManager(int maxStepSize, boolean enableVisualizer, boolean deleteE /** * This creates a new {@link NetworkManager} with the given capacity. - * + * * @param maxStepSize * The maximum amount of nodes a {@link Network} can have */ @@ -81,7 +81,7 @@ public NetworkManager(int maxStepSize) { /** * This method returns the limit of nodes a {@link Network} can have. * This value is read from the {@link Config} file. - * + * * @return the maximum amount of nodes a {@link Network} can have */ public int getMaxSize() { @@ -90,7 +90,7 @@ public int getMaxSize() { /** * This returns whether the {@link Network} visualizer is enabled. - * + * * @return Whether the {@link Network} visualizer is enabled */ public boolean isVisualizerEnabled() { @@ -100,7 +100,7 @@ public boolean isVisualizerEnabled() { /** * This returns whether excess items from a {@link CargoNet} should be voided * instead of being dropped to the ground. - * + * * @return Whether to delete excess items */ public boolean isItemDeletionEnabled() { @@ -110,7 +110,7 @@ public boolean isItemDeletionEnabled() { /** * This returns a {@link List} of every {@link Network} on the {@link Server}. * The returned {@link List} is not modifiable. - * + * * @return A {@link List} containing every {@link Network} on the {@link Server} */ @Nonnull @@ -156,28 +156,31 @@ public List getNetworksFromLocation(@Nullable Location l, /** * This registers a given {@link Network}. - * + * * @param network * The {@link Network} to register */ public void registerNetwork(@Nonnull Network network) { Validate.notNull(network, "Cannot register a null Network"); - Debug.log(TestCase.ENERGYNET, "Registering network @ " + LocationUtils.locationToString(network.getRegulator())); + Debug.log( + TestCase.ENERGYNET, "Registering network @ " + LocationUtils.locationToString(network.getRegulator())); networks.add(network); } /** * This removes a {@link Network} from the network system. - * + * * @param network * The {@link Network} to remove */ public void unregisterNetwork(@Nonnull Network network) { Validate.notNull(network, "Cannot unregister a null Network"); - Debug.log(TestCase.ENERGYNET, "Unregistering network @ " + LocationUtils.locationToString(network.getRegulator())); + Debug.log( + TestCase.ENERGYNET, + "Unregistering network @ " + LocationUtils.locationToString(network.getRegulator())); networks.remove(network); } @@ -185,7 +188,7 @@ public void unregisterNetwork(@Nonnull Network network) { /** * This method updates every {@link Network} found at the given {@link Location}. * More precisely, {@link Network#markDirty(Location)} will be called. - * + * * @param l * The {@link Location} to update */ @@ -206,7 +209,7 @@ public void updateAllNetworks(@Nonnull Location l) { /* * Only a Slimefun block can be part of a Network. * This check helps to speed up performance. - * + * * (Skip for Unit Tests as they don't support block info yet) */ if (!StorageCacheUtils.hasBlock(l) && Slimefun.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) { @@ -218,8 +221,11 @@ public void updateAllNetworks(@Nonnull Location l) { network.markDirty(l); } } catch (Exception x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "An Exception was thrown while causing a networks update @ " + new BlockPosition(l)); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "An Exception was thrown while causing a networks update @ " + new BlockPosition(l)); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java index 2cce2bb796..6431327ae7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/AbstractItemNetwork.java @@ -1,14 +1,17 @@ package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +import io.github.thebusybiscuit.slimefun4.api.network.Network; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - +import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; +import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -17,17 +20,10 @@ import org.bukkit.block.data.Directional; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.network.Network; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - -import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; -import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; - /** * An abstract super class of {@link CargoNet} that handles * interactions with ChestTerminal. - * + * * @author TheBusyBiscuit * */ @@ -59,7 +55,8 @@ protected Optional getAttachedBlock(@Nonnull Location l) { return Optional.of(block.getRelative(cached)); } - BlockFace face = ((Directional) block.getBlockData()).getFacing().getOppositeFace(); + BlockFace face = + ((Directional) block.getBlockData()).getFacing().getOppositeFace(); connectorCache.put(l, face); return Optional.of(block.getRelative(face)); } @@ -77,7 +74,7 @@ public void markDirty(@Nonnull Location l) { /** * This will mark the {@link ItemFilter} of the given node dirty. * It will also invalidate the cached rotation. - * + * * @param node * The {@link Location} of the cargo node */ @@ -131,5 +128,4 @@ private void filter(@Nullable ItemStack stack, List items, return filter; } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java index b3ca0c5b35..5b399d65c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java @@ -7,13 +7,6 @@ import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent; import io.github.thebusybiscuit.slimefun4.core.attributes.HologramOwner; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; @@ -22,12 +15,18 @@ import java.util.Optional; import java.util.Set; import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; /** * The {@link CargoNet} is a type of {@link Network} which deals with {@link ItemStack} transportation. * It is also an extension of {@link AbstractItemNetwork} which provides methods to deal * with the addon ChestTerminal. - * + * * @author meiamsome * @author Poslovitch * @author John000708 @@ -49,7 +48,9 @@ public class CargoNet extends AbstractItemNetwork implements HologramOwner { private int tickDelayThreshold = 0; public static @Nullable CargoNet getNetworkFromLocation(@Nonnull Location l) { - return Slimefun.getNetworkManager().getNetworkFromLocation(l, CargoNet.class).orElse(null); + return Slimefun.getNetworkManager() + .getNetworkFromLocation(l, CargoNet.class) + .orElse(null); } public static @Nonnull CargoNet getNetworkFromLocationOrCreate(@Nonnull Location l) { @@ -66,7 +67,7 @@ public class CargoNet extends AbstractItemNetwork implements HologramOwner { /** * This constructs a new {@link CargoNet} at the given {@link Location}. - * + * * @param l * The {@link Location} marking the manager of this {@link Network}. */ @@ -95,9 +96,7 @@ public NetworkComponent classifyLocation(@Nonnull Location l) { return switch (data.getSfId()) { case "CARGO_MANAGER" -> NetworkComponent.REGULATOR; case "CARGO_NODE" -> NetworkComponent.CONNECTOR; - case "CARGO_NODE_INPUT", - "CARGO_NODE_OUTPUT", - "CARGO_NODE_OUTPUT_ADVANCED" -> NetworkComponent.TERMINUS; + case "CARGO_NODE_INPUT", "CARGO_NODE_OUTPUT", "CARGO_NODE_OUTPUT_ADVANCED" -> NetworkComponent.TERMINUS; default -> null; }; } @@ -115,8 +114,7 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom var data = StorageCacheUtils.getBlock(l); switch (data.getSfId()) { case "CARGO_NODE_INPUT" -> inputNodes.add(l); - case "CARGO_NODE_OUTPUT", - "CARGO_NODE_OUTPUT_ADVANCED" -> outputNodes.add(l); + case "CARGO_NODE_OUTPUT", "CARGO_NODE_OUTPUT_ADVANCED" -> outputNodes.add(l); default -> {} } } @@ -216,10 +214,10 @@ public void tick(@Nonnull Block b) { * This method returns the frequency a given node is set to. * Should there be invalid data this method it will fall back to zero in * order to preserve the integrity of the {@link CargoNet}. - * + * * @param node * The {@link Location} of our cargo node - * + * * @return The frequency of the given node */ private static int getFrequency(@Nonnull Location node) { @@ -238,7 +236,19 @@ private static int getFrequency(@Nonnull Location node) { if (frequency == null) { return 0; } else if (!CommonPatterns.NUMERIC.matcher(frequency).matches()) { - Slimefun.logger().log(Level.SEVERE, () -> "Failed to parse a Cargo Node Frequency (" + node.getWorld().getName() + " - " + node.getBlockX() + ',' + node.getBlockY() + ',' + node.getBlockZ() + "): " + frequency); + Slimefun.logger() + .log( + Level.SEVERE, + () -> "Failed to parse a Cargo Node Frequency (" + + node.getWorld().getName() + + " - " + + node.getBlockX() + + ',' + + node.getBlockY() + + ',' + + node.getBlockZ() + + "): " + + frequency); return 0; } else { return Integer.parseInt(frequency); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java index 4c7f65d6d5..e008392b9b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java @@ -9,14 +9,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; -import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -27,15 +19,22 @@ import java.util.Objects; import java.util.Optional; import java.util.logging.Level; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemStack; /** * The {@link CargoNetworkTask} is the actual {@link Runnable} responsible for moving {@link ItemStack ItemStacks} * around the {@link CargoNet}. - * + * * Inbefore this was just a method in the {@link CargoNet} class. * However for aesthetic reasons but mainly to prevent the Cargo Task from showing up as * "lambda:xyz-123" in timing reports... this was moved. - * + * * @see CargoNet * @see CargoUtils * @see AbstractItemNetwork @@ -80,7 +79,12 @@ public void run() { timestamp += Slimefun.getProfiler().closeEntry(entry.getKey(), inputNode, nodeTimestamp); } } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "An Exception was caught while ticking a Cargo network @ " + new BlockPosition(network.getRegulator())); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "An Exception was caught while ticking a Cargo network @ " + + new BlockPosition(network.getRegulator())); } // Submit a timings report @@ -88,7 +92,8 @@ public void run() { } @ParametersAreNonnullByDefault - private void routeItems(Location inputNode, Block inputTarget, int frequency, Map> outputNodes) { + private void routeItems( + Location inputNode, Block inputTarget, int frequency, Map> outputNodes) { ItemStackAndInteger slot = CargoUtils.withdraw(network, inventories, inputNode.getBlock(), inputTarget); if (slot == null) { @@ -122,7 +127,8 @@ private void insertItem(Block inputTarget, int previousSlot, ItemStack item) { if (rest != null && !manager.isItemDeletionEnabled()) { // If the item still couldn't be inserted, simply drop it on the ground - SlimefunUtils.spawnItem(inputTarget.getLocation().add(0, 1, 0), rest, ItemSpawnReason.CARGO_OVERFLOW); + SlimefunUtils.spawnItem( + inputTarget.getLocation().add(0, 1, 0), rest, ItemSpawnReason.CARGO_OVERFLOW); } } } else { @@ -132,14 +138,14 @@ private void insertItem(Block inputTarget, int previousSlot, ItemStack item) { if (menu.getItemInSlot(previousSlot) == null) { menu.replaceExistingItem(previousSlot, item); } else if (!manager.isItemDeletionEnabled()) { - SlimefunUtils.spawnItem(inputTarget.getLocation().add(0, 1, 0), item, ItemSpawnReason.CARGO_OVERFLOW); + SlimefunUtils.spawnItem( + inputTarget.getLocation().add(0, 1, 0), item, ItemSpawnReason.CARGO_OVERFLOW); } } } } - @Nullable - @ParametersAreNonnullByDefault + @Nullable @ParametersAreNonnullByDefault private ItemStack distributeItem(ItemStack stack, Location inputNode, List outputNodes) { ItemStack item = stack; @@ -172,7 +178,8 @@ private ItemStack distributeItem(ItemStack stack, Location inputNode, List outputNodes) { } } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java index a13c4ce23d..53ab71a358 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java @@ -11,6 +11,9 @@ import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import io.papermc.lib.PaperLib; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu; import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; @@ -26,15 +29,11 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import java.util.Map; - /** * This is a helper class for the {@link CargoNet} which provides * a free static utility methods to let the {@link CargoNet} interact with * an {@link Inventory} or {@link BlockMenu}. - * + * * @author TheBusyBiscuit * @author Walshy * @author DNx5 @@ -45,7 +44,7 @@ final class CargoUtils { /** * These are the slots where our filter items sit. */ - private static final int[] FILTER_SLOTS = { 19, 20, 21, 28, 29, 30, 37, 38, 39 }; + private static final int[] FILTER_SLOTS = {19, 20, 21, 28, 29, 30, 37, 38, 39}; /** * This is a utility class and should not be instantiated. @@ -56,10 +55,10 @@ private CargoUtils() {} /** * This is a performance-saving shortcut to quickly test whether a given * {@link Block} might be an {@link InventoryHolder} or not. - * + * * @param block * The {@link Block} to check - * + * * @return Whether this {@link Block} represents a {@link BlockState} that is an {@link InventoryHolder} */ static boolean hasInventory(@Nullable Block block) { @@ -78,27 +77,27 @@ static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item) if (item != null && item.getType().isFuel()) { if (isSmeltable(item, true)) { // Any non-smeltable items should not land in the upper slot - return new int[] { 0, 2 }; + return new int[] {0, 2}; } else { - return new int[] { 1, 2 }; + return new int[] {1, 2}; } } else { - return new int[] { 0, 1 }; + return new int[] {0, 1}; } } else if (inv instanceof BrewerInventory) { if (isPotion(item)) { // Slots for potions - return new int[] { 0, 3 }; + return new int[] {0, 3}; } else if (item != null && item.getType() == Material.BLAZE_POWDER) { // Blaze Powder slot - return new int[] { 4, 5 }; + return new int[] {4, 5}; } else { // Input slot - return new int[] { 3, 4 }; + return new int[] {3, 4}; } } else { // Slot 0-size - return new int[] { 0, inv.getSize() }; + return new int[] {0, inv.getSize()}; } } @@ -106,18 +105,22 @@ static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item) static int[] getOutputSlotRange(@Nonnull Inventory inv) { if (inv instanceof FurnaceInventory) { // Slot 2-3 - return new int[] { 2, 3 }; + return new int[] {2, 3}; } else if (inv instanceof BrewerInventory) { // Slot 0-3 - return new int[] { 0, 3 }; + return new int[] {0, 3}; } else { // Slot 0-size - return new int[] { 0, inv.getSize() }; + return new int[] {0, inv.getSize()}; } } - @Nullable - static ItemStack withdraw(AbstractItemNetwork network, Map inventories, Block node, Block target, ItemStack template) { + @Nullable static ItemStack withdraw( + AbstractItemNetwork network, + Map inventories, + Block node, + Block target, + ItemStack template) { DirtyChestMenu menu = getChestMenu(target); if (menu == null) { @@ -150,7 +153,8 @@ static ItemStack withdraw(AbstractItemNetwork network, Map ItemStackWrapper wrapperItemInSlot = ItemStackWrapper.wrap(is); - if (SlimefunUtils.isItemSimilar(wrapperItemInSlot, wrapperTemplate, true) && matchesFilter(network, node, wrapperItemInSlot)) { + if (SlimefunUtils.isItemSimilar(wrapperItemInSlot, wrapperTemplate, true) + && matchesFilter(network, node, wrapperItemInSlot)) { if (is.getAmount() > template.getAmount()) { is.setAmount(is.getAmount() - template.getAmount()); menu.replaceExistingItem(slot, is); @@ -165,8 +169,8 @@ static ItemStack withdraw(AbstractItemNetwork network, Map return null; } - @Nullable - static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block node, ItemStack template, Inventory inv) { + @Nullable static ItemStack withdrawFromVanillaInventory( + AbstractItemNetwork network, Block node, ItemStack template, Inventory inv) { ItemStack[] contents = inv.getContents(); int[] range = getOutputSlotRange(inv); int minSlot = range[0]; @@ -182,7 +186,8 @@ static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block } ItemStackWrapper wrapperInSlot = ItemStackWrapper.wrap(itemInSlot); - if (SlimefunUtils.isItemSimilar(wrapperInSlot, wrapper, true, false) && matchesFilter(network, node, wrapperInSlot)) { + if (SlimefunUtils.isItemSimilar(wrapperInSlot, wrapper, true, false) + && matchesFilter(network, node, wrapperInSlot)) { if (itemInSlot.getAmount() > template.getAmount()) { itemInSlot.setAmount(itemInSlot.getAmount() - template.getAmount()); return template; @@ -197,8 +202,8 @@ static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block return null; } - @Nullable - static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map inventories, Block node, Block target) { + @Nullable static ItemStackAndInteger withdraw( + AbstractItemNetwork network, Map inventories, Block node, Block target) { DirtyChestMenu menu = getChestMenu(target); if (menu != null) { @@ -239,8 +244,8 @@ static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map inventories, Block node, Block target, boolean smartFill, ItemStack stack, ItemStackWrapper wrapper) { + @Nullable static ItemStack insert( + AbstractItemNetwork network, + Map inventories, + Block node, + Block target, + boolean smartFill, + ItemStack stack, + ItemStackWrapper wrapper) { Debug.log(TestCase.CARGO_INPUT_TESTING, "CargoUtils#insert"); if (!matchesFilter(network, node, stack)) { return stack; @@ -333,8 +344,8 @@ static ItemStack insert(AbstractItemNetwork network, Map in return stack; } - @Nullable - private static ItemStack insertIntoVanillaInventory(@Nonnull ItemStack stack, @Nonnull ItemStackWrapper wrapper, boolean smartFill, @Nonnull Inventory inv) { + @Nullable private static ItemStack insertIntoVanillaInventory( + @Nonnull ItemStack stack, @Nonnull ItemStackWrapper wrapper, boolean smartFill, @Nonnull Inventory inv) { /* * If the Inventory does not accept this Item Type, bounce the item back. * Example: Shulker boxes within shulker boxes (fixes #2662) @@ -386,8 +397,7 @@ private static ItemStack insertIntoVanillaInventory(@Nonnull ItemStack stack, @N return stack; } - @Nullable - static DirtyChestMenu getChestMenu(@Nonnull Block block) { + @Nullable static DirtyChestMenu getChestMenu(@Nonnull Block block) { return StorageCacheUtils.getMenu(block.getLocation()); } @@ -404,12 +414,12 @@ static boolean matchesFilter(@Nonnull AbstractItemNetwork network, @Nonnull Bloc * The lazy-option is a performance-saver since actually calculating this can be quite expensive. * For the current applicational purposes a quick check for any wooden logs is sufficient. * Otherwise the "lazyness" can be turned off in the future. - * + * * @param stack * The {@link ItemStack} to test * @param lazy * Whether or not to perform a "lazy" but performance-saving check - * + * * @return Whether the given {@link ItemStack} can be smelted or not */ private static boolean isSmeltable(@Nullable ItemStack stack, boolean lazy) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java index 315406b943..a04e87cbb1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemFilter.java @@ -10,23 +10,22 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoNode; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; -import org.bukkit.Material; -import org.bukkit.block.Block; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Predicate; +import javax.annotation.Nonnull; +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.inventory.ItemStack; /** * The {@link ItemFilter} is a performance-optimization for our {@link CargoNet}. * It is a snapshot of a cargo node's configuration. - * + * * @author TheBusyBiscuit - * + * * @see CargoNet * @see CargoNetworkTask * @@ -64,7 +63,7 @@ class ItemFilter implements Predicate { /** * This creates a new {@link ItemFilter} for the given {@link Block}. * This will copy all settings from that {@link Block} to this filter. - * + * * @param b * The {@link Block} */ @@ -75,7 +74,7 @@ public ItemFilter(@Nonnull Block b) { /** * This updates or refreshes the {@link ItemFilter} to copy the settings * from the given {@link Block}. It takes a new snapshot. - * + * * @param b * The {@link Block} */ @@ -89,16 +88,15 @@ public void update(@Nonnull Block b) { update(blockData); } else { isLoading = true; - Slimefun.getDatabaseManager().getBlockDataController().loadBlockDataAsync( - blockData, - new IAsyncReadCallback<>() { + Slimefun.getDatabaseManager() + .getBlockDataController() + .loadBlockDataAsync(blockData, new IAsyncReadCallback<>() { @Override public void onResult(SlimefunBlockData result) { update(blockData); isLoading = false; } - } - ); + }); } } @@ -131,7 +129,10 @@ private void update(SlimefunBlockData blockData) { * However if that ever happens again, we will know the reason and be able * to send a warning in response to it. */ - item.warn("Cargo Node was marked as a 'filtering' node but has an insufficient inventory size (" + inventorySize + ")"); + item.warn("Cargo Node was marked as a 'filtering' node but has an insufficient inventory size" + + " (" + + inventorySize + + ")"); return; } @@ -158,7 +159,7 @@ private void update(SlimefunBlockData blockData) { /** * This will clear the {@link ItemFilter} and reject any * {@link ItemStack}. - * + * * @param rejectOnMatch * Whether the item should be rejected on matches */ @@ -170,7 +171,7 @@ private void clear(boolean rejectOnMatch) { /** * Whether this {@link ItemFilter} is outdated and needs to be refreshed. - * + * * @return Whether the filter is outdated. */ public boolean isDirty() { @@ -243,5 +244,4 @@ public boolean test(@Nonnull ItemStack item) { return rejectOnMatch; } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java index 6ed5e6621d..4842e25be9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemStackAndInteger.java @@ -1,12 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.networks.cargo; +import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper; - class ItemStackAndInteger { private ItemStack item; @@ -49,5 +47,4 @@ private void initializeItem() { this.item = copy; } } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java index 96c7abbb70..2db100dad9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/package-info.java @@ -2,4 +2,4 @@ * This package holds an implementation of {@link io.github.thebusybiscuit.slimefun4.api.network.Network} * that is responsible for item transportation. */ -package io.github.thebusybiscuit.slimefun4.core.networks.cargo; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.networks.cargo; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java index 0ca42bf1f1..c64a1f36f6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java @@ -29,10 +29,10 @@ /** * The {@link EnergyNet} is an implementation of {@link Network} that deals with * electrical energy being sent from and to nodes. - * + * * @author meiamsome * @author TheBusyBiscuit - * + * * @see Network * @see EnergyNetComponent * @see EnergyNetProvider @@ -100,10 +100,8 @@ public NetworkComponent classifyLocation(@Nonnull Location l) { return null; } else { return switch (component.getEnergyComponentType()) { - case CONNECTOR, - CAPACITOR -> NetworkComponent.CONNECTOR; - case CONSUMER, - GENERATOR -> NetworkComponent.TERMINUS; + case CONNECTOR, CAPACITOR -> NetworkComponent.CONNECTOR; + case CONSUMER, GENERATOR -> NetworkComponent.TERMINUS; default -> null; }; } @@ -130,7 +128,8 @@ public void onClassificationChange(Location l, NetworkComponent from, NetworkCom if (component instanceof EnergyNetProvider provider) { generators.put(l, provider); } else if (component instanceof SlimefunItem item) { - item.warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!"); + item.warn("This Item is marked as a GENERATOR but does not implement the interface" + + " EnergyNetProvider!"); } break; default: @@ -144,7 +143,8 @@ public void tick(@Nonnull Block b) { if (!regulator.equals(b.getLocation())) { updateHologram(b, "&4检测到附近有其他调节器"); - Slimefun.getProfiler().closeEntry(b.getLocation(), SlimefunItems.ENERGY_REGULATOR.getItem(), timestamp.get()); + Slimefun.getProfiler() + .closeEntry(b.getLocation(), SlimefunItems.ENERGY_REGULATOR.getItem(), timestamp.get()); return; } @@ -324,8 +324,7 @@ private void updateHologram(@Nonnull Block b, double supply, double demand) { } } - @Nullable - private static EnergyNetComponent getComponent(@Nonnull Location l) { + @Nullable private static EnergyNetComponent getComponent(@Nonnull Location l) { SlimefunItem item = StorageCacheUtils.getSfItem(l); if (item instanceof EnergyNetComponent component) { @@ -344,18 +343,19 @@ private static EnergyNetComponent getComponent(@Nonnull Location l) { * * @return The {@link EnergyNet} at that {@link Location}, or {@code null} */ - @Nullable - public static EnergyNet getNetworkFromLocation(@Nonnull Location l) { - return Slimefun.getNetworkManager().getNetworkFromLocation(l, EnergyNet.class).orElse(null); + @Nullable public static EnergyNet getNetworkFromLocation(@Nonnull Location l) { + return Slimefun.getNetworkManager() + .getNetworkFromLocation(l, EnergyNet.class) + .orElse(null); } /** * This attempts to get an {@link EnergyNet} from a given {@link Location}. * If no suitable {@link EnergyNet} could be found, a new one will be created. - * + * * @param l * The target {@link Location} - * + * * @return The {@link EnergyNet} at that {@link Location}, or a new one */ @Nonnull diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java index 0f1fc00852..5623e80160 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNetComponentType.java @@ -4,7 +4,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector; import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor; - import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator; import org.bukkit.block.Block; @@ -49,5 +48,4 @@ public enum EnergyNetComponentType { * other options. */ NONE; - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java index d5061d1036..34694e2608 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/package-info.java @@ -2,4 +2,4 @@ * This package holds an implementation of {@link io.github.thebusybiscuit.slimefun4.api.network.Network} * that is responsible for transmitting energy. */ -package io.github.thebusybiscuit.slimefun4.core.networks.energy; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.networks.energy; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java index 5f4e747aff..81163d607e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/package-info.java @@ -3,4 +3,4 @@ * class, such as the {@link io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager} and also the subpackages * for actual implementations of the {@link io.github.thebusybiscuit.slimefun4.api.network.Network} class. */ -package io.github.thebusybiscuit.slimefun4.core.networks; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.networks; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java index 4a303ab0e0..4c27464ee3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/package-info.java @@ -2,4 +2,4 @@ * This package holds the core systems of Slimefun, these are not necessarily used as an API * but rather provide the core functionality of this {@link org.bukkit.plugin.Plugin}. */ -package io.github.thebusybiscuit.slimefun4.core; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java index 06e4c27d68..cd80124363 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/AutoSavingService.java @@ -2,17 +2,16 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import org.bukkit.block.Block; -import org.bukkit.entity.Player; - -import javax.annotation.Nonnull; import java.util.Iterator; import java.util.logging.Level; +import javax.annotation.Nonnull; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; /** * This Service is responsible for automatically saving {@link Player} and {@link Block} * data. - * + * * @author TheBusyBiscuit * */ @@ -22,7 +21,7 @@ public class AutoSavingService { /** * This method starts the {@link AutoSavingService} with the given interval. - * + * * @param plugin * The current instance of Slimefun * @param interval @@ -32,12 +31,15 @@ public void start(@Nonnull Slimefun plugin, int interval) { this.interval = interval; plugin.getServer().getScheduler().runTaskTimer(plugin, this::saveAllPlayers, 2000L, interval * 60L * 20L); - plugin.getServer().getScheduler().runTaskTimerAsynchronously( - plugin, - () -> Slimefun.getDatabaseManager().getBlockDataController().saveAllBlockInventories(), - 2000L, - interval * 60L * 20L - ); + plugin.getServer() + .getScheduler() + .runTaskTimerAsynchronously( + plugin, + () -> Slimefun.getDatabaseManager() + .getBlockDataController() + .saveAllBlockInventories(), + 2000L, + interval * 60L * 20L); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java index e00d1c2982..a64354d6c9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java @@ -2,9 +2,6 @@ import com.xzavier0722.mc.plugin.slimefun4.storage.controller.StorageType; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import org.apache.commons.lang.Validate; - -import javax.annotation.Nonnull; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -19,10 +16,12 @@ import java.util.logging.Level; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; +import javax.annotation.Nonnull; +import org.apache.commons.lang.Validate; /** * This Service creates a Backup of your Slimefun world data on every server shutdown. - * + * * @author TheBusyBiscuit * */ @@ -76,7 +75,12 @@ public void run() { Slimefun.logger().log(Level.WARNING, "无法创建备份文件: {0}", file.getName()); } } catch (IOException x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "An Exception occurred while creating a backup for Slimefun " + Slimefun.getVersion()); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "An Exception occurred while creating a backup for Slimefun " + + Slimefun.getVersion()); } } } @@ -109,7 +113,8 @@ private void addFile(ZipOutputStream output, File file, String path) throws IOEx output.closeEntry(); } - private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directory, @Nonnull String zipPath) throws IOException { + private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directory, @Nonnull String zipPath) + throws IOException { for (File file : directory.listFiles()) { addFile(output, file, zipPath); } @@ -117,17 +122,19 @@ private void addDirectory(@Nonnull ZipOutputStream output, @Nonnull File directo /** * This method will delete old backups. - * + * * @param backups * The {@link List} of all backups - * + * * @throws IOException * An {@link IOException} is thrown if a {@link File} could not be deleted */ private void purgeBackups(@Nonnull List backups) throws IOException { Collections.sort(backups, (a, b) -> { - LocalDateTime time1 = LocalDateTime.parse(a.getName().substring(0, a.getName().length() - 4), format); - LocalDateTime time2 = LocalDateTime.parse(b.getName().substring(0, b.getName().length() - 4), format); + LocalDateTime time1 = + LocalDateTime.parse(a.getName().substring(0, a.getName().length() - 4), format); + LocalDateTime time2 = + LocalDateTime.parse(b.getName().substring(0, b.getName().length() - 4), format); return time2.compareTo(time1); }); @@ -136,5 +143,4 @@ private void purgeBackups(@Nonnull List backups) throws IOException { Files.delete(backups.get(i).toPath()); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java index 69c9579286..f2bde71bb3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java @@ -1,12 +1,12 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import io.papermc.lib.PaperLib; import java.util.Optional; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Keyed; @@ -20,15 +20,12 @@ import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.papermc.lib.PaperLib; - /** * The {@link BlockDataService} is similar to the {@link CustomItemDataService}, * it is responsible for storing NBT data inside a {@link TileState}. - * + * * This is used to speed up performance and prevent - * + * * @author TheBusyBiscuit * */ @@ -40,7 +37,7 @@ public class BlockDataService implements Keyed { * This creates a new {@link BlockDataService} for the given {@link Plugin}. * The {@link Plugin} and key will together form a {@link NamespacedKey} used to store * data on a {@link TileState}. - * + * * @param plugin * The {@link Plugin} responsible for this service * @param key @@ -57,7 +54,7 @@ public NamespacedKey getKey() { /** * This will store the given {@link String} inside the NBT data of the given {@link Block} - * + * * @param b * The {@link Block} in which to store the given value * @param value @@ -82,19 +79,26 @@ public void setBlockData(@Nonnull Block b, @Nonnull String value) { Slimefun.logger().log(Level.SEVERE, "Please check if your Server Software is up to date!"); String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName(); - Slimefun.logger().log(Level.SEVERE, () -> serverSoftware + " | " + Bukkit.getVersion() + " | " + Bukkit.getBukkitVersion()); - - Slimefun.logger().log(Level.SEVERE, "An Exception was thrown while trying to set Persistent Data for a Block", x); + Slimefun.logger() + .log( + Level.SEVERE, + () -> serverSoftware + " | " + Bukkit.getVersion() + " | " + Bukkit.getBukkitVersion()); + + Slimefun.logger() + .log( + Level.SEVERE, + "An Exception was thrown while trying to set Persistent Data for a Block", + x); } } } /** * This method returns the NBT data previously stored inside this {@link Block}. - * + * * @param b * The {@link Block} to retrieve data from - * + * * @return The stored value */ public Optional getBlockData(@Nonnull Block b) { @@ -110,8 +114,7 @@ public Optional getBlockData(@Nonnull Block b) { } } - @Nullable - private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState state) { + @Nullable private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState state) { if (state instanceof TileState tileState) { return tileState.getPersistentDataContainer(); } else { @@ -123,13 +126,13 @@ private PersistentDataContainer getPersistentDataContainer(@Nonnull BlockState s * This method checks whether the given {@link Material} is a Tile Entity. * This is used to determine whether the {@link Block} produced by this {@link Material} * produces a {@link TileState}, making it useable as a {@link PersistentDataHolder}. - * + * * Due to {@link Block#getState()} being a very expensive call performance-wise though, * this simple lookup method is used instead. - * + * * @param type * The {@link Material} to check for - * + * * @return Whether the given {@link Material} is considered a Tile Entity */ public boolean isTileEntity(@Nullable Material type) { @@ -140,5 +143,4 @@ public boolean isTileEntity(@Nullable Material type) { return SlimefunTag.TILE_ENTITIES.isTagged(type); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java index e9617b7eec..ad16ded8f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomItemDataService.java @@ -1,10 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import java.util.Optional; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.Keyed; import org.bukkit.Material; @@ -15,16 +15,13 @@ import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; - /** * This Service is responsible for applying NBT data to a {@link SlimefunItemStack}. * This is used to ensure that the id of a {@link SlimefunItem} is stored alongside any * {@link ItemStack} at all times. - * + * * @author TheBusyBiscuit - * + * * @see SlimefunItemStack * */ @@ -38,7 +35,7 @@ public class CustomItemDataService implements Keyed { /** * This creates a new {@link CustomItemDataService} for the given {@link Plugin} and the * provided data key. - * + * * @param plugin * The {@link Plugin} for this service to use * @param key @@ -57,7 +54,7 @@ public NamespacedKey getKey() { /** * This method stores the given id on the provided {@link ItemStack} via * persistent data. - * + * * @param item * The {@link ItemStack} to store data on * @param id @@ -75,7 +72,7 @@ public void setItemData(@Nonnull ItemStack item, @Nonnull String id) { /** * This method stores the given id on the provided {@link ItemMeta} via * persistent data. - * + * * @param meta * The {@link ItemMeta} to store data on * @param id @@ -93,10 +90,10 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) { * This method returns an {@link Optional} holding the data stored on the given {@link ItemStack}. * The {@link Optional} will be empty if the given {@link ItemStack} is null, doesn't have any {@link ItemMeta} * or if the requested data simply does not exist on that {@link ItemStack}. - * + * * @param item * The {@link ItemStack} to check - * + * * @return An {@link Optional} describing the result */ public @Nonnull Optional getItemData(@Nullable ItemStack item) { @@ -110,10 +107,10 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) { /** * This method returns an {@link Optional}, either empty or holding the data stored * on the given {@link ItemMeta}. - * + * * @param meta * The {@link ItemMeta} to check - * + * * @return An {@link Optional} describing the result */ public @Nonnull Optional getItemData(@Nonnull ItemMeta meta) { @@ -127,12 +124,12 @@ public void setItemData(@Nonnull ItemMeta meta, @Nonnull String id) { * This method compares the custom data stored on two {@link ItemMeta} objects. * This method will only return {@literal true} if both {@link ItemMeta}s contain * custom data and if both of their data values are equal. - * + * * @param meta1 * The first {@link ItemMeta} * @param meta2 * The second {@link ItemMeta} - * + * * @return Whether both metas have data on them and its the same. */ public boolean hasEqualItemData(@Nonnull ItemMeta meta1, @Nonnull ItemMeta meta2) { @@ -157,5 +154,4 @@ public boolean hasEqualItemData(@Nonnull ItemMeta meta1, @Nonnull ItemMeta meta2 return false; } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java index 5d55e8b03c..0cbc47ae4b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/CustomTextureService.java @@ -1,26 +1,23 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; import java.util.Collection; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * This Service is responsible for applying custom model data to any {@link SlimefunItemStack} * if a Server Owner configured Slimefun to use those. @@ -57,7 +54,14 @@ public class CustomTextureService { */ public CustomTextureService(@Nonnull Config config) { this.config = config; - config.getConfiguration().options().header("This file is used to assign items from Slimefun or any of its addons\n" + "the 'CustomModelData' NBT tag. This can be used in conjunction with a custom resource pack\n" + "to give items custom textures.\n0 means there is no data assigned to that item.\n\n" + "There is no official Slimefun resource pack at the moment."); + config.getConfiguration() + .options() + .header("This file is used to assign items from Slimefun or any of its addons\n" + + "the 'CustomModelData' NBT tag. This can be used in conjunction with a custom" + + " resource pack\n" + + "to give items custom textures.\n" + + "0 means there is no data assigned to that item.\n\n" + + "There is no official Slimefun resource pack at the moment."); config.getConfiguration().options().copyHeader(true); } @@ -106,8 +110,7 @@ private void loadDefaultValues() { } } - @Nullable - public String getVersion() { + @Nullable public String getVersion() { return version; } @@ -169,5 +172,4 @@ public void setTexture(@Nonnull ItemMeta im, @Nonnull String id) { int data = getModelData(id); im.setCustomModelData(data == 0 ? null : data); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java index e0c176b571..14733c9f94 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java @@ -1,5 +1,11 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; +import io.github.thebusybiscuit.slimefun4.core.services.localization.LanguageFile; +import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; +import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; @@ -11,11 +17,9 @@ import java.util.Set; import java.util.logging.Level; import java.util.stream.Collectors; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.NamespacedKey; import org.bukkit.Server; @@ -26,13 +30,6 @@ import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; -import io.github.thebusybiscuit.slimefun4.core.services.localization.Language; -import io.github.thebusybiscuit.slimefun4.core.services.localization.LanguageFile; -import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; - /** * As the name suggests, this Service is responsible for Localization. * It is used for managing the {@link Language} of a {@link Player} and the entire {@link Server}. @@ -54,7 +51,8 @@ public class LocalizationService extends SlimefunLocalization { private final NamespacedKey languageKey; private final Language defaultLanguage; - public LocalizationService(@Nonnull Slimefun plugin, @Nullable String prefix, @Nullable String serverDefaultLanguage) { + public LocalizationService( + @Nonnull Slimefun plugin, @Nullable String prefix, @Nullable String serverDefaultLanguage) { super(plugin); this.plugin = plugin; @@ -64,7 +62,8 @@ public LocalizationService(@Nonnull Slimefun plugin, @Nullable String prefix, @N if (serverDefaultLanguage != null) { translationsEnabled = Slimefun.getCfg().getBoolean("options.enable-translations"); - defaultLanguage = new Language(serverDefaultLanguage, "11b3188fd44902f72602bd7c2141f5a70673a411adb3d81862c69e536166b"); + defaultLanguage = new Language( + serverDefaultLanguage, "11b3188fd44902f72602bd7c2141f5a70673a411adb3d81862c69e536166b"); defaultLanguage.setFile(LanguageFile.MESSAGES, getConfig().getConfiguration()); loadEmbeddedLanguages(); @@ -79,7 +78,8 @@ public LocalizationService(@Nonnull Slimefun plugin, @Nullable String prefix, @N setLanguage(serverDefaultLanguage, !serverDefaultLanguage.equals(language)); } else { setLanguage("en", false); - plugin.getLogger().log(Level.WARNING, "Could not recognize the given language: \"{0}\"", serverDefaultLanguage); + plugin.getLogger() + .log(Level.WARNING, "Could not recognize the given language: \"{0}\"", serverDefaultLanguage); } Slimefun.logger().log(Level.INFO, "Available languages: {0}", String.join(", ", languages.keySet())); @@ -111,8 +111,7 @@ public NamespacedKey getKey() { } @Override - @Nullable - public Language getLanguage(@Nonnull String id) { + @Nullable public Language getLanguage(@Nonnull String id) { Validate.notNull(id, "The language id cannot be null"); return languages.get(id); } @@ -187,7 +186,8 @@ private void setLanguage(@Nonnull String language, boolean reset) { // Loading in the defaults from our resources folder String path = "/languages/" + language + "/messages.yml"; - try (BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) { + try (BufferedReader reader = new BufferedReader( + new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) { FileConfiguration config = YamlConfiguration.loadConfiguration(reader); getConfig().getConfiguration().setDefaults(config); } catch (IOException e) { @@ -212,7 +212,8 @@ protected void addLanguage(@Nonnull String id, @Nonnull String texture) { Language language = new Language(id, texture); for (LanguageFile file : LanguageFile.values()) { - FileConfiguration defaults = file == LanguageFile.MESSAGES ? getConfig().getConfiguration() : null; + FileConfiguration defaults = + file == LanguageFile.MESSAGES ? getConfig().getConfiguration() : null; FileConfiguration config = getConfigurationFromStream(file.getFilePath(language), defaults); language.setFile(file, config); } @@ -252,7 +253,8 @@ public double calculateProgress(@Nonnull Language lang) { return Math.min(NumberUtils.reparseDouble(100.0 * (matches / (double) defaultKeys.size())), 100.0); } - private @Nonnull FileConfiguration getConfigurationFromStream(@Nonnull String file, @Nullable FileConfiguration defaults) { + private @Nonnull FileConfiguration getConfigurationFromStream( + @Nonnull String file, @Nullable FileConfiguration defaults) { InputStream inputStream = plugin.getClass().getResourceAsStream(file); if (inputStream == null) { @@ -281,4 +283,4 @@ public double calculateProgress(@Nonnull Language lang) { return new YamlConfiguration(); } } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java index e186004c4e..da1f1e9911 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.bakedlibs.dough.common.CommonPatterns; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; @@ -10,20 +12,14 @@ import java.nio.file.StandardCopyOption; import java.util.concurrent.atomic.AtomicInteger; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import org.bukkit.plugin.Plugin; - -import io.github.bakedlibs.dough.common.CommonPatterns; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - import kong.unirest.GetRequest; import kong.unirest.HttpResponse; import kong.unirest.JsonNode; import kong.unirest.Unirest; import kong.unirest.UnirestException; +import org.bukkit.plugin.Plugin; /** * This Class represents a Metrics Service that sends data to https://bstats.org/ @@ -74,17 +70,17 @@ public class MetricsService { static { // @formatter:off (We want this to stay this nicely aligned :D ) Unirest.config() - .concurrency(2, 1) - .setDefaultHeader("User-Agent", "MetricsModule Auto-Updater") - .setDefaultHeader("Accept", "application/vnd.github.v3+json") - .enableCookieManagement(false) - .cookieSpec("ignoreCookies"); + .concurrency(2, 1) + .setDefaultHeader("User-Agent", "MetricsModule Auto-Updater") + .setDefaultHeader("Accept", "application/vnd.github.v3+json") + .enableCookieManagement(false) + .cookieSpec("ignoreCookies"); // @formatter:on } /** * This constructs a new instance of our {@link MetricsService}. - * + * * @param plugin * Our {@link Slimefun} instance */ @@ -117,7 +113,9 @@ public void start() { * Load the jar file into a child class loader using the Slimefun * PluginClassLoader as a parent. */ - moduleClassLoader = URLClassLoader.newInstance(new URL[] { metricsModuleFile.toURI().toURL() }, plugin.getClass().getClassLoader()); + moduleClassLoader = URLClassLoader.newInstance( + new URL[] {metricsModuleFile.toURI().toURL()}, + plugin.getClass().getClassLoader()); Class metricsClass = moduleClassLoader.loadClass("dev.walshy.sfmetrics.MetricsModule"); metricVersion = metricsClass.getPackage().getImplementationVersion(); @@ -142,7 +140,11 @@ public void start() { start.invoke(null); plugin.getLogger().info("Metrics build #" + version + " started."); } catch (InvocationTargetException e) { - plugin.getLogger().log(Level.WARNING, "An exception was thrown while starting the metrics module", e.getCause()); + plugin.getLogger() + .log( + Level.WARNING, + "An exception was thrown while starting the metrics module", + e.getCause()); } catch (Exception | LinkageError e) { plugin.getLogger().log(Level.WARNING, "Failed to start metrics.", e); } @@ -162,7 +164,8 @@ public void cleanUp() { moduleClassLoader.close(); } } catch (IOException e) { - plugin.getLogger().log(Level.WARNING, "Could not clean up module class loader. Some memory may have been leaked."); + plugin.getLogger() + .log(Level.WARNING, "Could not clean up module class loader. Some memory may have been leaked."); } } @@ -172,11 +175,12 @@ public void cleanUp() { * * @param currentVersion * The current version which is being used. - * + * * @return if there is an update available. */ public boolean checkForUpdate(@Nullable String currentVersion) { - if (currentVersion == null || !CommonPatterns.NUMERIC.matcher(currentVersion).matches()) { + if (currentVersion == null + || !CommonPatterns.NUMERIC.matcher(currentVersion).matches()) { return false; } @@ -239,16 +243,26 @@ private boolean download(int version) { GetRequest request = Unirest.get(DOWNLOAD_URL + "/" + version + "/" + JAR_NAME + ".jar"); HttpResponse response = request.downloadMonitor((b, fileName, bytesWritten, totalBytes) -> { - int percent = (int) (20 * (Math.round((((double) bytesWritten / totalBytes) * 100) / 20))); - - if (percent != 0 && percent != lastPercentPosted.get()) { - plugin.getLogger().info("# Downloading... " + percent + "% " + "(" + bytesWritten + "/" + totalBytes + " bytes)"); - lastPercentPosted.set(percent); - } - }).asFile(file.getPath()); + int percent = (int) (20 * (Math.round((((double) bytesWritten / totalBytes) * 100) / 20))); + + if (percent != 0 && percent != lastPercentPosted.get()) { + plugin.getLogger() + .info("# Downloading... " + + percent + + "% " + + "(" + + bytesWritten + + "/" + + totalBytes + + " bytes)"); + lastPercentPosted.set(percent); + } + }) + .asFile(file.getPath()); if (response.isSuccess()) { - plugin.getLogger().log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] { JAR_NAME, version }); + plugin.getLogger() + .log(Level.INFO, "Successfully downloaded {0} build: #{1}", new Object[] {JAR_NAME, version}); // Replace the metric file with the new one cleanUp(); @@ -259,9 +273,19 @@ private boolean download(int version) { return true; } } catch (UnirestException e) { - plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down? Response: {0}", e.getMessage()); + plugin.getLogger() + .log( + Level.WARNING, + "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down?" + + " Response: {0}", + e.getMessage()); } catch (IOException e) { - plugin.getLogger().log(Level.WARNING, "Failed to replace the old metric file with the new one. Please do this manually! Error: {0}", e.getMessage()); + plugin.getLogger() + .log( + Level.WARNING, + "Failed to replace the old metric file with the new one. Please do this manually!" + + " Error: {0}", + e.getMessage()); } return false; @@ -274,8 +298,7 @@ private boolean download(int version) { * * @return The current version or null if not loaded. */ - @Nullable - public String getVersion() { + @Nullable public String getVersion() { return metricVersion; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java index 3919122699..e7fe8bef7e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java @@ -1,15 +1,16 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.bakedlibs.dough.recipes.MinecraftRecipe; +import io.github.bakedlibs.dough.recipes.RecipeSnapshot; +import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; import java.util.Collection; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Optional; import java.util.function.Consumer; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.Keyed; @@ -22,10 +23,6 @@ import org.bukkit.inventory.ShapedRecipe; import org.bukkit.plugin.Plugin; -import io.github.bakedlibs.dough.recipes.MinecraftRecipe; -import io.github.bakedlibs.dough.recipes.RecipeSnapshot; -import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide; - /** * This Service is responsible for accessing a {@link RecipeSnapshot}. * This snapshot contains a compiled list of all recipes that could be found on the @@ -194,5 +191,4 @@ public boolean isSmeltable(@Nullable ItemStack input) { return Bukkit.getRecipe(key); } } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java index a0dc615d30..1667d924c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java @@ -1,5 +1,11 @@ package io.github.thebusybiscuit.slimefun4.core.services; +import io.github.bakedlibs.dough.collections.OptionalMap; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.io.File; import java.util.Collections; import java.util.HashMap; @@ -10,23 +16,14 @@ import java.util.Optional; import java.util.Set; import java.util.UUID; - import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.World; -import io.github.bakedlibs.dough.collections.OptionalMap; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - /** * This Service is responsible for disabling a {@link SlimefunItem} in a certain {@link World}. - * + * * @author TheBusyBiscuit * */ @@ -44,7 +41,7 @@ public PerWorldSettingsService(@Nonnull Slimefun plugin) { /** * This method will forcefully load all currently active Worlds to load up their settings. - * + * * @param worlds * An {@link Iterable} of {@link World Worlds} to load */ @@ -56,7 +53,7 @@ public void load(@Nonnull Iterable worlds) { /** * This method loads the given {@link World} if it was not loaded before. - * + * * @param world * The {@link World} to load */ @@ -67,12 +64,12 @@ public void load(@Nonnull World world) { /** * This method checks whether the given {@link SlimefunItem} is enabled in the given {@link World}. - * + * * @param world * The {@link World} to check * @param item * The {@link SlimefunItem} that should be checked - * + * * @return Whether the given {@link SlimefunItem} is enabled in that {@link World} */ public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) { @@ -90,7 +87,7 @@ public boolean isEnabled(@Nonnull World world, @Nonnull SlimefunItem item) { /** * This method enables or disables the given {@link SlimefunItem} in the specified {@link World}. - * + * * @param world * The {@link World} in which to disable or enable the given {@link SlimefunItem} * @param item @@ -113,7 +110,7 @@ public void setEnabled(@Nonnull World world, @Nonnull SlimefunItem item, boolean /** * This method enables or disables the given {@link World}. - * + * * @param world * The {@link World} to enable or disable * @param enabled @@ -132,10 +129,10 @@ public void setEnabled(@Nonnull World world, boolean enabled) { /** * This checks whether the given {@link World} is enabled or not. - * + * * @param world * The {@link World} to check - * + * * @return Whether this {@link World} is enabled */ public boolean isWorldEnabled(@Nonnull World world) { @@ -147,25 +144,26 @@ public boolean isWorldEnabled(@Nonnull World world) { /** * This method checks whether the given {@link SlimefunAddon} is enabled in that {@link World}. - * + * * @param world * The {@link World} to check * @param addon * The {@link SlimefunAddon} to check - * + * * @return Whether this addon is enabled in that {@link World} */ public boolean isAddonEnabled(@Nonnull World world, @Nonnull SlimefunAddon addon) { Validate.notNull(world, "World cannot be null"); Validate.notNull(addon, "Addon cannot be null"); - return isWorldEnabled(world) && disabledAddons.getOrDefault(addon, Collections.emptySet()).contains(world.getName()); + return isWorldEnabled(world) + && disabledAddons.getOrDefault(addon, Collections.emptySet()).contains(world.getName()); } /** * This will forcefully save the settings for that {@link World}. * This should only be called if you altered the settings while the {@link Server} was still running. * This writes to a {@link File} so it can be a heavy operation. - * + * * @param world * The {@link World} to save */ @@ -198,7 +196,18 @@ private Set loadWorldFromConfig(@Nonnull World world) { Set items = new LinkedHashSet<>(); Config config = getConfig(world); - config.getConfiguration().options().header("This file is used to disable certain items in a particular world.\nYou can set any item to 'false' to disable it in the world '" + name + "'.\nYou can also disable an entire addon from Slimefun by setting the respective\nvalue of 'enabled' for that Addon.\n\nItems which are disabled in this world will not show up in the Slimefun Guide.\nYou won't be able to use these items either. Using them will result in a warning message."); + config.getConfiguration() + .options() + .header("This file is used to disable certain items in a particular world.\n" + + "You can set any item to 'false' to disable it in the world '" + + name + + "'.\n" + + "You can also disable an entire addon from Slimefun by setting the respective\n" + + "value of 'enabled' for that Addon.\n\n" + + "Items which are disabled in this world will not show up in the Slimefun" + + " Guide.\n" + + "You won't be able to use these items either. Using them will result in a" + + " warning message."); config.getConfiguration().options().copyHeader(true); config.setDefaultValue("enabled", true); @@ -217,7 +226,8 @@ private Set loadWorldFromConfig(@Nonnull World world) { } } - private void loadItemsFromWorldConfig(@Nonnull String worldName, @Nonnull Config config, @Nonnull Set items) { + private void loadItemsFromWorldConfig( + @Nonnull String worldName, @Nonnull Config config, @Nonnull Set items) { for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { if (item != null) { String addon = item.getAddon().getName().toLowerCase(Locale.ROOT); @@ -241,10 +251,10 @@ private void loadItemsFromWorldConfig(@Nonnull String worldName, @Nonnull Config /** * This method returns the relevant {@link Config} for the given {@link World} - * + * * @param world * Our {@link World} - * + * * @return The corresponding {@link Config} */ @Nonnull @@ -252,5 +262,4 @@ private Config getConfig(@Nonnull World world) { Validate.notNull(world, "World cannot be null"); return new Config(plugin, "world-settings/" + world.getName() + ".yml"); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java index 6dad4691ab..7d61e86c32 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java @@ -4,7 +4,6 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.io.File; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -19,9 +18,9 @@ /** * This Service is responsible for handling the {@link Permission} of a * {@link SlimefunItem}. - * + * * You can set up these {@link Permission} nodes inside the {@code permissions.yml} file. - * + * * @author TheBusyBiscuit * */ @@ -34,12 +33,15 @@ public PermissionsService(@Nonnull Slimefun plugin) { config = new Config(plugin, "permissions.yml"); // @formatter:off - config.getConfiguration().options().header( - "This file is used to assign permission nodes to items from Slimefun or any of its addons.\n" + - "To assign an item a certain permission node you simply have to set the 'permission' attribute\n" + - "to your desired permission node.\n" + - "You can also customize the text that is displayed when a Player does not have that permission." - ); + config.getConfiguration() + .options() + .header("This file is used to assign permission nodes to items from Slimefun or any of its" + + " addons.\n" + + "To assign an item a certain permission node you simply have to set the" + + " 'permission' attribute\n" + + "to your desired permission node.\n" + + "You can also customize the text that is displayed when a Player does not have" + + " that permission."); // @formatter:on config.getConfiguration().options().copyHeader(true); @@ -68,7 +70,8 @@ public void update(@Nonnull SlimefunItem item, boolean save) { String path = item.getId() + ".permission"; config.setDefaultValue(path, "none"); - config.setDefaultValue(item.getId() + ".lore", new String[]{"&rYou do not have the permission", "&rto access this item."}); + config.setDefaultValue( + item.getId() + ".lore", new String[] {"&rYou do not have the permission", "&rto access this item."}); permissions.put(item.getId(), config.getString(path)); @@ -80,12 +83,12 @@ public void update(@Nonnull SlimefunItem item, boolean save) { /** * This method checks whether the given {@link Permissible} has the {@link Permission} * to access the given {@link SlimefunItem}. - * + * * @param p * The {@link Permissible} to check * @param item * The {@link SlimefunItem} in question - * + * * @return Whether the {@link Permissible} has the required {@link Permission} */ public boolean hasPermission(Permissible p, SlimefunItem item) { @@ -102,10 +105,10 @@ public boolean hasPermission(Permissible p, SlimefunItem item) { * This returns the associated {@link Permission} with the given {@link SlimefunItem}. * It actually returns an {@link Optional}, {@link Optional#empty()} means that there was no * {@link Permission} set for the given {@link SlimefunItem} - * + * * @param item * The {@link SlimefunItem} to retrieve the {@link Permission} for. - * + * * @return An {@link Optional} holding the {@link Permission} as a {@link String} or an empty {@link Optional} */ @Nonnull @@ -122,7 +125,7 @@ public Optional getPermission(@Nonnull SlimefunItem item) { /** * This method sets the {@link Permission} for a given {@link SlimefunItem}. - * + * * @param item * The {@link SlimefunItem} to modify * @param permission @@ -147,14 +150,13 @@ public void save() { /** * This returns the lore to display for a given {@link SlimefunItem} when a {@link Player} * does not have the required permission node. - * + * * @param item * The {@link SlimefunItem} - * + * * @return The configured lore to display */ public @Nonnull List getLore(@Nonnull SlimefunItem item) { return config.getStringList(item.getId() + ".lore"); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java index ff0cd97522..f983488b6a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java @@ -86,8 +86,7 @@ public int getBuildNumber() { * This will start the {@link UpdaterService} and check for updates. * If it can find an update it will automatically be installed. */ - public void start() { - } + public void start() {} /** * This returns whether the {@link PluginUpdater} is enabled or not. @@ -103,11 +102,9 @@ public boolean isEnabled() { /** * This method is called when the {@link UpdaterService} was disabled. */ - public void disable() { - } + public void disable() {} private void printBorder() { plugin.getLogger().log(Level.WARNING, "#######################################################"); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java index acaf68cd8d..b4dfe7c512 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ActivityCallback.java @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; -import javax.annotation.Nonnull; import java.time.LocalDateTime; +import javax.annotation.Nonnull; @FunctionalInterface interface ActivityCallback { @@ -14,5 +14,4 @@ interface ActivityCallback { * @param date The {@link LocalDateTime} of the last activity */ void accept(int forks, int stars, @Nonnull LocalDateTime date); - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java index 7dd4970552..6e232dd9bf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java @@ -1,16 +1,13 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - import kong.unirest.JsonNode; import kong.unirest.json.JSONArray; import kong.unirest.json.JSONObject; @@ -82,7 +79,7 @@ private void loadConfiguration() { /** * This returns whether this {@link ContributionsConnector} has finished its task. - * + * * @return Whether it is finished */ public boolean hasFinished() { @@ -96,7 +93,8 @@ public void onSuccess(@Nonnull JsonNode response) { if (response.isArray()) { computeContributors(response.getArray()); } else { - Slimefun.logger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); + Slimefun.logger() + .log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java index e8f8b75f8d..c72d188ac5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; +import io.github.bakedlibs.dough.data.TriStateOptional; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import java.util.ArrayList; import java.util.Comparator; import java.util.List; @@ -8,17 +11,11 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; -import io.github.bakedlibs.dough.data.TriStateOptional; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; - /** * Represents a {@link Contributor} who contributed to a GitHub repository. * @@ -112,8 +109,7 @@ public String getMinecraftName() { * * @return The GitHub profile of this {@link Contributor} */ - @Nullable - public String getProfile() { + @Nullable public String getProfile() { return profileLink; } @@ -243,7 +239,11 @@ public int getTotalContributions() { */ @Nonnull public String getDisplayName() { - return ChatColor.GRAY + githubUsername + (!githubUsername.equals(minecraftUsername) ? ChatColor.DARK_GRAY + " (MC: " + minecraftUsername + ")" : ""); + return ChatColor.GRAY + + githubUsername + + (!githubUsername.equals(minecraftUsername) + ? ChatColor.DARK_GRAY + " (MC: " + minecraftUsername + ")" + : ""); } /** @@ -256,4 +256,4 @@ public String getDisplayName() { public int getPosition() { return -getTotalContributions(); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java index 7391a8d673..d4b565769a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributorRole.java @@ -14,7 +14,6 @@ * */ enum ContributorRole { - DEVELOPER("developer"), RESOURCEPACK_ARTIST("resourcepack"), TRANSLATOR("translator"), @@ -30,5 +29,4 @@ enum ContributorRole { String getId() { return id; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java index 82ea03259f..df804f41f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubActivityConnector.java @@ -1,15 +1,13 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; - -import kong.unirest.JsonNode; -import kong.unirest.json.JSONObject; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; import java.time.LocalDateTime; import java.util.HashMap; import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +import kong.unirest.JsonNode; +import kong.unirest.json.JSONObject; class GitHubActivityConnector extends GitHubConnector { @@ -45,5 +43,4 @@ public String getEndpoint() { public Map getParameters() { return new HashMap<>(); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java index 422ed31787..035a13d2f9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java @@ -1,5 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -10,12 +11,8 @@ import java.nio.charset.StandardCharsets; import java.util.Map; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - import kong.unirest.HttpResponse; import kong.unirest.JsonNode; import kong.unirest.Unirest; @@ -26,7 +23,7 @@ * The {@link GitHubConnector} is used to connect to the GitHub API service. * It can be extended by subclasses, this just serves as an abstract super class for * other connectors. - * + * * @author TheBusyBiscuit * @author Walshy */ @@ -41,7 +38,7 @@ abstract class GitHubConnector { /** * This creates a new {@link GitHubConnector} for the given repository. - * + * * @param github * Our instance of {@link GitHubService} * @param repository @@ -54,7 +51,7 @@ abstract class GitHubConnector { /** * This returns the name of our cache {@link File}. - * + * * @return The cache {@link File} name */ @Nonnull @@ -63,7 +60,7 @@ abstract class GitHubConnector { /** * This is our {@link URL} endpoint. * It is the suffix of the {@link URL} we want to connect to. - * + * * @return Our endpoint */ @Nonnull @@ -71,7 +68,7 @@ abstract class GitHubConnector { /** * This {@link Map} contains the query parameters for our {@link URL}. - * + * * @return A {@link Map} with our query parameters */ @Nonnull @@ -79,7 +76,7 @@ abstract class GitHubConnector { /** * This method is called when the connection finished successfully. - * + * * @param response * The response */ @@ -117,7 +114,9 @@ void download() { writeCacheFile(response.getBody()); } else { if (github.isLoggingEnabled()) { - Slimefun.logger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { url, response.getStatus(), response.getBody() }); + Slimefun.logger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { + url, response.getStatus(), response.getBody() + }); } // It has the cached file, let's just read that then @@ -149,12 +148,14 @@ void download() { } } - @Nullable - private JsonNode readCacheFile() { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { + @Nullable private JsonNode readCacheFile() { + try (BufferedReader reader = + new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { return new JsonNode(reader.readLine()); } catch (IOException | JSONException e) { - Slimefun.logger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] { file.getName(), e.getClass().getSimpleName(), e.getMessage() }); + Slimefun.logger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] { + file.getName(), e.getClass().getSimpleName(), e.getMessage() + }); return null; } } @@ -163,7 +164,9 @@ private void writeCacheFile(@Nonnull JsonNode node) { try (FileOutputStream output = new FileOutputStream(file)) { output.write(node.toString().getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { - Slimefun.logger().log(Level.WARNING, "Failed to populate GitHub cache: {0} - {1}", new Object[] { e.getClass().getSimpleName(), e.getMessage() }); + Slimefun.logger().log(Level.WARNING, "Failed to populate GitHub cache: {0} - {1}", new Object[] { + e.getClass().getSimpleName(), e.getMessage() + }); } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java index 81cd1ac5d3..ab2dac5480 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java @@ -1,14 +1,11 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - import kong.unirest.JsonNode; import kong.unirest.json.JSONArray; import kong.unirest.json.JSONObject; @@ -43,7 +40,8 @@ public void onSuccess(@Nonnull JsonNode response) { callback.accept(issues, pullRequests); } else { - Slimefun.logger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); + Slimefun.logger() + .log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); } } @@ -63,5 +61,4 @@ public Map getParameters() { parameters.put("per_page", 100); return parameters; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java index 17d158d27f..5ba15770e4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubService.java @@ -1,5 +1,8 @@ package io.github.thebusybiscuit.slimefun4.core.services.github; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import java.io.File; import java.time.LocalDateTime; import java.util.HashSet; @@ -10,21 +13,15 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.TimeUnit; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; - /** * This Service is responsible for grabbing every {@link Contributor} to this project * from GitHub and holding data associated to the project repository, such * as open issues or pending pull requests. - * + * * @author TheBusyBiscuit * */ @@ -48,7 +45,7 @@ public class GitHubService { /** * This creates a new {@link GitHubService} for the given repository. - * + * * @param repository * The repository to create this {@link GitHubService} for */ @@ -62,7 +59,7 @@ public GitHubService(@Nonnull String repository) { /** * This will start the {@link GitHubService} and run the asynchronous {@link GitHubTask} * every so often to update its data. - * + * * @param plugin * Our instance of {@link Slimefun} */ @@ -104,7 +101,8 @@ private void addContributor(@Nonnull String name, @Nonnull String role) { contributors.put(name, contributor); } - public @Nonnull Contributor addContributor(@Nonnull String minecraftName, @Nonnull String profileURL, @Nonnull String role, int commits) { + public @Nonnull Contributor addContributor( + @Nonnull String minecraftName, @Nonnull String profileURL, @Nonnull String role, int commits) { Validate.notNull(minecraftName, "Minecraft username must not be null."); Validate.notNull(profileURL, "GitHub profile url must not be null."); Validate.notNull(role, "Role should not be null."); @@ -112,7 +110,8 @@ private void addContributor(@Nonnull String name, @Nonnull String role) { String username = profileURL.substring(profileURL.lastIndexOf('/') + 1); - Contributor contributor = contributors.computeIfAbsent(username, key -> new Contributor(minecraftName, profileURL)); + Contributor contributor = + contributors.computeIfAbsent(username, key -> new Contributor(minecraftName, profileURL)); contributor.setContributions(role, commits); contributor.setUniqueId(uuidCache.getUUID(minecraftName)); return contributor; @@ -141,7 +140,8 @@ private void loadConnectors(boolean logging) { connectors.add(new ContributionsConnector(this, "wiki", 1, "Slimefun/Wiki", ContributorRole.WIKI_EDITOR)); // TheBusyBiscuit/Slimefun4-Resourcepack - connectors.add(new ContributionsConnector(this, "resourcepack", 1, "Slimefun/Resourcepack", ContributorRole.RESOURCEPACK_ARTIST)); + connectors.add(new ContributionsConnector( + this, "resourcepack", 1, "Slimefun/Resourcepack", ContributorRole.RESOURCEPACK_ARTIST)); // Issues and Pull Requests connectors.add(new GitHubIssuesConnector(this, repository, (issues, pullRequests) -> { @@ -167,7 +167,7 @@ protected boolean isLoggingEnabled() { /** * This returns the {@link Contributor Contributors} to this project. - * + * * @return A {@link ConcurrentMap} containing all {@link Contributor Contributors} */ public @Nonnull ConcurrentMap getContributors() { @@ -176,7 +176,7 @@ protected boolean isLoggingEnabled() { /** * This returns the amount of forks of our repository - * + * * @return The amount of forks */ public int getForks() { @@ -185,7 +185,7 @@ public int getForks() { /** * This method returns the amount of stargazers of the repository. - * + * * @return The amount of people who starred the repository */ public int getStars() { @@ -194,7 +194,7 @@ public int getStars() { /** * This returns the amount of open Issues on our repository. - * + * * @return The amount of open issues */ public int getOpenIssues() { @@ -203,7 +203,7 @@ public int getOpenIssues() { /** * Returns the id of Slimefun's GitHub Repository. (e.g. "Slimefun/Slimefun4"). - * + * * @return The id of our GitHub Repository */ public @Nonnull String getRepository() { @@ -212,7 +212,7 @@ public int getOpenIssues() { /** * This method returns the amount of pending pull requests. - * + * * @return The amount of pending pull requests */ public int getPendingPullRequests() { @@ -221,7 +221,7 @@ public int getPendingPullRequests() { /** * This returns the date and time of the last commit to this repository. - * + * * @return A {@link LocalDateTime} object representing the date and time of the latest commit */ public @Nonnull LocalDateTime getLastUpdate() { @@ -252,10 +252,10 @@ protected void saveCache() { /** * This returns the cached skin texture for a given username. - * + * * @param username * The minecraft username - * + * * @return The cached skin texture for that user (or null) */ protected @Nullable String getCachedTexture(@Nonnull String username) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java index 3c1f294291..5146085578 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java @@ -4,7 +4,6 @@ import io.github.bakedlibs.dough.skins.UUIDLookup; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.io.File; -import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Map; import java.util.Optional; @@ -21,9 +20,9 @@ /** * This {@link GitHubTask} represents a {@link Runnable} that is run every X minutes. * It retrieves every {@link Contributor} of this project from GitHub. - * + * * @author TheBusyBiscuit - * + * * @see GitHubService * @see Contributor * @@ -75,13 +74,16 @@ private void grabTextures() { } } - if (requests >= MAX_REQUESTS_PER_MINUTE && Slimefun.instance() != null && Slimefun.instance().isEnabled()) { + if (requests >= MAX_REQUESTS_PER_MINUTE + && Slimefun.instance() != null + && Slimefun.instance().isEnabled()) { // Slow down API requests and wait a minute after more than x requests were made Bukkit.getScheduler().runTaskLaterAsynchronously(Slimefun.instance(), this::grabTextures, 2 * 60 * 20L); } for (GitHubConnector connector : gitHubService.getConnectors()) { - if (connector instanceof ContributionsConnector contributionsConnector && !contributionsConnector.hasFinished()) { + if (connector instanceof ContributionsConnector contributionsConnector + && !contributionsConnector.hasFinished()) { return; } } @@ -111,14 +113,23 @@ private int requestTexture(@Nonnull Contributor contributor, @Nonnull Map skins) throws InterruptedException, ExecutionException, TimeoutException { + private @Nullable String pullTexture(@Nonnull Contributor contributor, @Nonnull Map skins) + throws InterruptedException, ExecutionException, TimeoutException { Optional uuid = contributor.getUniqueId(); if (!uuid.isPresent()) { - CompletableFuture future = UUIDLookup.getUuidFromUsername(Slimefun.instance(), contributor.getMinecraftName()); + CompletableFuture future = + UUIDLookup.getUuidFromUsername(Slimefun.instance(), contributor.getMinecraftName()); if (future.isCompletedExceptionally()) { return null; @@ -158,5 +171,4 @@ private int requestTexture(@Nonnull Contributor contributor, @Nonnull Map hologram.setLabel(label)); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java index d081769ee3..ca03be89fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/holograms/package-info.java @@ -2,4 +2,4 @@ * This package contains everything related to the * {@link io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService}. */ -package io.github.thebusybiscuit.slimefun4.core.services.holograms; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.services.holograms; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java index a9f7c7f59a..75f3c458c1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java @@ -1,24 +1,21 @@ package io.github.thebusybiscuit.slimefun4.core.services.localization; +import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; +import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import java.util.Arrays; import java.util.EnumMap; import java.util.Locale; import java.util.Map; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - import org.apache.commons.lang.Validate; import org.bukkit.Server; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - /** * This Class represents a {@link Language} that Slimefun can recognize and use. * @@ -82,8 +79,7 @@ public double getTranslationProgress() { } } - @Nullable - FileConfiguration getFile(@Nonnull LanguageFile file) { + @Nullable FileConfiguration getFile(@Nonnull LanguageFile file) { return files.get(file); } @@ -134,10 +130,7 @@ public String toString() { @Nonnull FileConfiguration[] getFiles() { // @formatter:off - return Arrays.stream(LanguageFile.valuesCached) - .map(this::getFile) - .toArray(FileConfiguration[]::new); + return Arrays.stream(LanguageFile.valuesCached).map(this::getFile).toArray(FileConfiguration[]::new); // @formatter:on } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java index e28d0022bb..52817d8b64 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguageFile.java @@ -1,7 +1,6 @@ package io.github.thebusybiscuit.slimefun4.core.services.localization; import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; /** @@ -14,7 +13,6 @@ * */ public enum LanguageFile { - MESSAGES("messages.yml"), CATEGORIES("categories.yml"), RECIPES("recipes.yml"), @@ -39,5 +37,4 @@ public String getFilePath(@Nonnull String languageId) { Validate.notNull(languageId, "Language id must not be null!"); return "/languages/" + languageId + '/' + fileName; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java index 6b5e4bc09d..297746f77b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/LanguagePreset.java @@ -2,21 +2,19 @@ import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.bukkit.inventory.ItemStack; /** * This enum holds info about a {@link Language} that is embedded in our resources folder. * Every enum constant holds the key of that {@link Language} as well as a texture hash * for the {@link ItemStack} to display. - * + * * @author TheBusyBiscuit - * + * * @see Language * */ public enum LanguagePreset { - ENGLISH("en", "a1701f21835a898b20759fb30a583a38b994abf60d3912ab4ce9f2311e74f72"), GERMAN("de", "5e7899b4806858697e283f084d9173fe487886453774626b24bd8cfecc77b3f"), FRENCH("fr", "51269a067ee37e63635ca1e723b676f139dc2dbddff96bbfef99d8b35c996bc"), @@ -50,7 +48,11 @@ public enum LanguagePreset { HEBREW("he", TextDirection.RIGHT_TO_LEFT, "1ba086a2cc7272cf5ba49c80248546c22e5ef1bab54120e8a8e5d9e75b6a"), ARABIC("ar", TextDirection.RIGHT_TO_LEFT, "a4be759a9cf7f0a19a7e8e62f23789ad1d21cebae38af9d9541676a3db001572"), TURKISH("tr", "9852b9aba3482348514c1034d0affe73545c9de679ae4647f99562b5e5f47d09"), - PERSIAN("fa", false, TextDirection.RIGHT_TO_LEFT, "5cd9badf1972583b663b44b1e027255de8f275aa1e89defcf77782ba6fcc652"), + PERSIAN( + "fa", + false, + TextDirection.RIGHT_TO_LEFT, + "5cd9badf1972583b663b44b1e027255de8f275aa1e89defcf77782ba6fcc652"), SERBIAN("sr", false, "5b0483a4f0ddf4fbbc977b127b3d294d7a869f995366e3f50f6b05a70f522510"), AFRIKAANS("af", false, "961a1eacc10524d1f45f23b0e487bb2fc33948d9676b418b19a3da0b109d0e3c"), MALAY("ms", false, "754b9041dea6db6db44750f1385a743adf653767b4b8802cad4c585dd3f5be46"), @@ -90,7 +92,7 @@ public enum LanguagePreset { /** * This returns the id of this {@link Language}. - * + * * @return The language code */ public @Nonnull String getLanguageCode() { @@ -100,7 +102,7 @@ public enum LanguagePreset { /** * This returns whether this {@link LanguagePreset} is "release-ready". * A release-ready {@link Language} will be available in RC builds of Slimefun. - * + * * @return Whether this {@link Language} is "release-ready" */ boolean isReadyForRelease() { @@ -112,7 +114,7 @@ boolean isReadyForRelease() { * This will be the flag of the corresponding country. * (Not accurate I know, but better than having all languages * look the same by using the same items) - * + * * @return The texture hash of this language */ public @Nonnull String getTexture() { @@ -122,7 +124,7 @@ boolean isReadyForRelease() { /** * This returns the direction of text for * this language. - * + * * @return The direction of text for this language */ public @Nonnull TextDirection getTextDirection() { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java index d6f2b50d18..e5880227bc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java @@ -1,16 +1,25 @@ package io.github.thebusybiscuit.slimefun4.core.services.localization; +import io.github.bakedlibs.dough.common.ChatColors; +import io.github.bakedlibs.dough.config.Config; +import io.github.bakedlibs.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; +import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; +import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.function.UnaryOperator; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - +import net.md_5.bungee.api.ChatMessageType; +import net.md_5.bungee.api.chat.BaseComponent; +import net.md_5.bungee.api.chat.TextComponent; import org.apache.commons.lang.Validate; import org.bukkit.ChatColor; import org.bukkit.Keyed; @@ -23,19 +32,6 @@ import org.bukkit.inventory.ItemFlag; import org.bukkit.inventory.ItemStack; -import io.github.bakedlibs.dough.common.ChatColors; -import io.github.bakedlibs.dough.config.Config; -import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion; -import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - -import net.md_5.bungee.api.ChatMessageType; -import net.md_5.bungee.api.chat.BaseComponent; -import net.md_5.bungee.api.chat.TextComponent; - /** * This is an abstract parent class of {@link LocalizationService}. * There is not really much more I can say besides that... @@ -68,7 +64,7 @@ protected void save() { * This returns the chat prefix for our messages. * Every message (unless explicitly omitted) will have this * prefix prepended. - * + * * @return The chat prefix */ public @Nonnull String getChatPrefix() { @@ -84,7 +80,6 @@ protected void save() { * * @return A {@link Language} with the given id or null */ - public abstract @Nullable Language getLanguage(@Nonnull String id); /** @@ -95,7 +90,6 @@ protected void save() { * * @return The {@link Language} that was selected by the given {@link Player} */ - public abstract @Nullable Language getLanguage(@Nonnull Player p); /** @@ -103,7 +97,6 @@ protected void save() { * * @return The default {@link Language} */ - public abstract @Nullable Language getDefaultLanguage(); /** @@ -123,7 +116,6 @@ protected void save() { * * @return A {@link Collection} that contains every installed {@link Language} */ - public abstract @Nonnull Collection getLanguages(); /** @@ -240,7 +232,9 @@ protected void loadEmbeddedLanguages() { Language language = getDefaultLanguage(); - String message = language == null ? null : language.getFile(LanguageFile.MESSAGES).getString(key); + String message = language == null + ? null + : language.getFile(LanguageFile.MESSAGES).getString(key); if (message == null) { return getDefaultFile(LanguageFile.MESSAGES).getString(key); @@ -323,14 +317,16 @@ protected void loadEmbeddedLanguages() { NamespacedKey key = recipeType.getKey(); return new CustomItemStack(item, meta -> { - String displayName = getStringOrNull(language, LanguageFile.RECIPES, key.getNamespace() + "." + key.getKey() + ".name"); + String displayName = + getStringOrNull(language, LanguageFile.RECIPES, key.getNamespace() + "." + key.getKey() + ".name"); // Set the display name if possible, else keep the default item name. if (displayName != null) { meta.setDisplayName(ChatColor.AQUA + displayName); } - List lore = getStringListOrNull(language, LanguageFile.RECIPES, key.getNamespace() + "." + key.getKey() + ".lore"); + List lore = getStringListOrNull( + language, LanguageFile.RECIPES, key.getNamespace() + "." + key.getKey() + ".lore"); // Set the lore if possible, else keep the default lore. if (lore != null) { @@ -442,4 +438,4 @@ public void sendMessages(CommandSender recipient, String key, UnaryOperator { int count = profiler.getBlocksOfId(entry.getKey()); String time = NumberUtils.getAsMillis(entry.getValue()); - String message = entry.getKey() + " - " + count + "x (%s)"; + String message = entry.getKey() + " - " + count + "x (%s)"; if (count <= 1) { return String.format(message, time); @@ -93,7 +97,12 @@ public void send(@Nonnull PerformanceInspector sender) { } @ParametersAreNonnullByDefault - private void summarizeTimings(int count, String name, PerformanceInspector inspector, Map map, Function, String> formatter) { + private void summarizeTimings( + int count, + String name, + PerformanceInspector inspector, + Map map, + Function, String> formatter) { Set> entrySet = map.entrySet(); List> results = inspector.getOrderType().sort(profiler, entrySet); String prefix = count + " " + name + (count != 1 ? 's' : ""); @@ -109,7 +118,11 @@ private void summarizeTimings(int count, String name, PerformanceInspector inspe @Nonnull @ParametersAreNonnullByDefault - private TextComponent summarizeAsTextComponent(int count, String prefix, List> results, Function, String> formatter) { + private TextComponent summarizeAsTextComponent( + int count, + String prefix, + List> results, + Function, String> formatter) { TextComponent component = new TextComponent(prefix); component.setColor(ChatColor.YELLOW); @@ -145,7 +158,12 @@ private TextComponent summarizeAsTextComponent(int count, String prefix, List> results, Function, String> formatter) { + private String summarizeAsString( + PerformanceInspector inspector, + int count, + String prefix, + List> results, + Function, String> formatter) { int shownEntries = 0; int hiddenEntries = 0; @@ -156,7 +174,9 @@ private String summarizeAsString(PerformanceInspector inspector, int count, Stri builder.append(ChatColor.YELLOW); for (Map.Entry entry : results) { - if (inspector.isVerbose() || (shownEntries < MAX_ITEMS && (shownEntries < MIN_ITEMS || entry.getValue() > VISIBILITY_THRESHOLD))) { + if (inspector.isVerbose() + || (shownEntries < MAX_ITEMS + && (shownEntries < MIN_ITEMS || entry.getValue() > VISIBILITY_THRESHOLD))) { builder.append("\n "); builder.append(ChatColor.stripColor(formatter.apply(entry))); shownEntries++; @@ -185,13 +205,14 @@ private String getPerformanceRating() { } builder.append(ChatColor.DARK_GRAY) - .append(":".repeat(Math.max(0, rest))) - .append(" - ") - .append(rating.getColor()).append(ChatUtils.humanize(rating.name())) - .append(ChatColor.GRAY) - .append(" (") - .append(NumberUtils.roundDecimalNumber(percentage)) - .append("%)"); + .append(":".repeat(Math.max(0, rest))) + .append(" - ") + .append(rating.getColor()) + .append(ChatUtils.humanize(rating.name())) + .append(ChatColor.GRAY) + .append(" (") + .append(NumberUtils.roundDecimalNumber(percentage)) + .append("%)"); return builder.toString(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java index 0bb60625fe..b0b549a920 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/ProfiledBlock.java @@ -1,21 +1,18 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler; +import io.github.bakedlibs.dough.blocks.BlockPosition; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import java.util.Objects; - import javax.annotation.Nonnull; - import org.bukkit.Location; import org.bukkit.World; import org.bukkit.block.Block; -import io.github.bakedlibs.dough.blocks.BlockPosition; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; - /** * This represents an entry in our {@link SlimefunProfiler}. * It is a modification of {@link BlockPosition} to be as memory-efficient as possible. - * + * * @author TheBusyBiscuit * */ @@ -40,7 +37,7 @@ final class ProfiledBlock { /** * This creates a new {@link ProfiledBlock} for the given {@link Location} and * the {@link SlimefunItem} found at this {@link Location}. - * + * * @param l * The {@link Location} * @param item @@ -55,7 +52,7 @@ final class ProfiledBlock { /** * This is just a dummy constructor. * Please only use this for comparisons or lookups. - * + * * @param b * A {@link Block} */ @@ -67,14 +64,14 @@ final class ProfiledBlock { /** * This compresses our {@link Location} into a long for more efficient memory usage - * + * * @param x * The x value * @param y * The y value * @param z * The z value - * + * * @return A {@link Long} representation of this {@link Location} */ private static long getLocationAsLong(int x, int y, int z) { @@ -155,5 +152,4 @@ public int hashCode() { long hilo = world.getUID().getMostSignificantBits() ^ world.getUID().getLeastSignificantBits(); return (int) (position ^ (position >> 32) ^ hilo ^ (hilo >> 32)); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java index bfec66ca6a..837a8855b9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java @@ -1,5 +1,10 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; +import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -12,9 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; import java.util.logging.Level; - import javax.annotation.Nonnull; - import org.apache.commons.lang.Validate; import org.bukkit.Chunk; import org.bukkit.Location; @@ -22,12 +25,6 @@ import org.bukkit.block.Block; import org.bukkit.scheduler.BukkitScheduler; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; - /** * The {@link SlimefunProfiler} works closely to the {@link TickerTask} and is * responsible for monitoring that task. @@ -60,7 +57,8 @@ public class SlimefunProfiler { * this data in split seconds. * So we cannot simply wait until the next server tick for this. */ - private final ExecutorService executor = Executors.newFixedThreadPool(threadFactory.getThreadCount(), threadFactory); + private final ExecutorService executor = + Executors.newFixedThreadPool(threadFactory.getThreadCount(), threadFactory); /** * All possible values of {@link PerformanceRating}. @@ -203,7 +201,10 @@ private void finishReport() { Iterator iterator = requests.iterator(); while (iterator.hasNext()) { - iterator.next().sendMessage("Your timings report has timed out, we were still waiting for " + queued.get() + " samples to be collected :/"); + iterator.next() + .sendMessage("Your timings report has timed out, we were still waiting for " + + queued.get() + + " samples to be collected :/"); iterator.remove(); } @@ -393,7 +394,8 @@ public String getTime(@Nonnull Block b) { public String getTime(@Nonnull Chunk chunk) { Validate.notNull(chunk, "Cannot get timings for a null Chunk"); - long time = getByChunk().getOrDefault(chunk.getWorld().getName() + " (" + chunk.getX() + ',' + chunk.getZ() + ')', 0L); + long time = getByChunk() + .getOrDefault(chunk.getWorld().getName() + " (" + chunk.getX() + ',' + chunk.getZ() + ')', 0L); return NumberUtils.getAsMillis(time); } @@ -416,4 +418,4 @@ public long getAndResetAverageTimings() { return l; } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java index d00f32f946..0cc8ffff80 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunThreadFactory.java @@ -1,7 +1,7 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler; -import javax.annotation.Nonnull; import java.util.concurrent.ThreadFactory; +import javax.annotation.Nonnull; /** * This is our {@link ThreadFactory} for the {@link SlimefunProfiler}. @@ -43,5 +43,4 @@ int getThreadCount() { public Thread newThread(@Nonnull Runnable runnable) { return new Thread(runnable, "Slimefun Profiler"); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SummaryOrderType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SummaryOrderType.java index 2f1e2ef195..37b99e0fd1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SummaryOrderType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SummaryOrderType.java @@ -1,12 +1,12 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler; -import javax.annotation.ParametersAreNonnullByDefault; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import javax.annotation.ParametersAreNonnullByDefault; /** * Holds the different types of ordering for summaries. @@ -30,7 +30,7 @@ public enum SummaryOrderType { @ParametersAreNonnullByDefault List> sort(SlimefunProfiler profiler, Set> entrySet) { - switch(this) { + switch (this) { case HIGHEST: return entrySet.stream() .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java index f4249a3cff..c8aceecbe4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/ConsolePerformanceInspector.java @@ -1,20 +1,18 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - -import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; import org.apache.commons.lang.Validate; import org.bukkit.command.CommandSender; import org.bukkit.command.ConsoleCommandSender; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; - /** * This implementation of {@link PerformanceInspector} refers to a {@link CommandSender} * which is preferabbly a {@link ConsoleCommandSender}. * But it can theoretically be used for any type of {@link CommandSender} as it uses uncolored texts. - * + * * @author TheBusyBiscuit * */ @@ -37,7 +35,7 @@ public class ConsolePerformanceInspector implements PerformanceInspector { /** * This creates a new {@link ConsolePerformanceInspector} for the given {@link CommandSender}. - * + * * @param console * The {@link CommandSender}, preferably a {@link ConsoleCommandSender} * @param verbose diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java index 8ce7811e3e..8b544dcb89 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/PlayerPerformanceInspector.java @@ -1,23 +1,19 @@ package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; +import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; import java.util.UUID; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - -import io.github.thebusybiscuit.slimefun4.core.services.profiler.SummaryOrderType; +import net.md_5.bungee.api.chat.TextComponent; import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.entity.Player; -import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector; - -import net.md_5.bungee.api.chat.TextComponent; - /** * This implementation of {@link PerformanceInspector} refers to a {@link Player}. * It also supports {@link TextComponent TextComponents} for rich text messages. - * + * * @author TheBusyBiscuit * */ @@ -35,7 +31,7 @@ public class PlayerPerformanceInspector implements PerformanceInspector { /** * This creates a new {@link PlayerPerformanceInspector} for the given {@link Player}. - * + * * @param player * The {@link Player} * @param orderType @@ -100,5 +96,4 @@ public void sendMessage(@Nonnull TextComponent component) { player.spigot().sendMessage(component); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java index e6921498b3..a68752e193 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/inspectors/package-info.java @@ -2,4 +2,4 @@ * This package holds the different implementations of * {@link io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector}. */ -package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/package-info.java index 44f03f890f..2c7a7929b8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/package-info.java @@ -6,4 +6,4 @@ * {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem SlimefunItems} that cause lag or performance * drops. */ -package io.github.thebusybiscuit.slimefun4.core.services.profiler; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.services.profiler; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java index 373e6be3db..c11473c398 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundConfiguration.java @@ -4,9 +4,9 @@ /** * This structure class holds configured values for a {@link SoundEffect}. - * + * * @author TheBusyBiscuit - * + * * @see SoundService * @see SoundEffect * @@ -34,5 +34,4 @@ public float getVolume() { public float getPitch() { return pitch; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java index d7cd73b2cd..2727df3ec8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundEffect.java @@ -1,25 +1,19 @@ package io.github.thebusybiscuit.slimefun4.core.services.sounds; -import java.util.Locale; +import com.google.common.base.Preconditions; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; - - -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - import org.bukkit.Location; import org.bukkit.Sound; import org.bukkit.SoundCategory; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import com.google.common.base.Preconditions; - /** * This enum holds references to all our sounds. - * + * * @author TheBusyBiscuit * @author J3fftw1 * @@ -28,7 +22,6 @@ * */ public enum SoundEffect { - ANCIENT_ALTAR_ITEM_CHECK_SOUND(Sound.ENTITY_ENDERMAN_TELEPORT, 1F, 2F), ANCIENT_ALTAR_ITEM_DROP_SOUND(Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1F, 1F), ANCIENT_ALTAR_ITEM_PICK_UP_SOUND(Sound.ENTITY_ITEM_PICKUP, 1F, 1F), @@ -50,11 +43,11 @@ public enum SoundEffect { COMPRESSOR_CRAFT_EXTEND_SOUND(Sound.BLOCK_PISTON_EXTEND, 1F, 1F), COOLER_CONSUME_SOUND(Sound.ENTITY_GENERIC_DRINK, 1F, 1F), CRUCIBLE_ADD_WATER_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), - CRUCIBLE_ADD_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F , 1F), + CRUCIBLE_ADD_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F, 1F), CRUCIBLE_BLOCK_BREAK_SOUND(Sound.BLOCK_METAL_BREAK, 1F, 1F), CRUCIBLE_GENERATE_LIQUID_SOUND(Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F), CRUCIBLE_INTERACT_SOUND(Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F), - CRUCIBLE_PLACE_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F , 1F), + CRUCIBLE_PLACE_LAVA_SOUND(Sound.BLOCK_LAVA_POP, 1F, 1F), CRUCIBLE_PLACE_WATER_SOUND(Sound.ENTITY_PLAYER_SPLASH, 1F, 1F), DEBUG_FISH_CLICK_SOUND(Sound.BLOCK_BAMBOO_PLACE, 1F, 1F), DIET_COOKIE_CONSUME_SOUND(Sound.ENTITY_GENERIC_EAT, 1F, 1F), diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java index 1c1d1133a8..d2f34e865e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/SoundService.java @@ -1,17 +1,14 @@ package io.github.thebusybiscuit.slimefun4.core.services.sounds; +import com.google.common.base.Preconditions; +import io.github.bakedlibs.dough.config.Config; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import java.util.EnumMap; import java.util.Map; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.Nullable; -import io.github.bakedlibs.dough.config.Config; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; - -import com.google.common.base.Preconditions; - /** * The {@link SoundService} is responsible for our sound management. * It allows server owners to fully customize their users' sound experience. @@ -34,11 +31,11 @@ public SoundService(@Nonnull Slimefun plugin) { config = new Config(plugin, "sounds.yml"); // @formatter:off - config.getConfiguration().options().header( - "This file is used to assign the sounds which Slimefun will play.\n" + - "You can fully customize any sound you want and even change their pitch\n" + - "and volume. To disable a sound, simply set the volume to zero.\n" - ); + config.getConfiguration() + .options() + .header("This file is used to assign the sounds which Slimefun will play.\n" + + "You can fully customize any sound you want and even change their pitch\n" + + "and volume. To disable a sound, simply set the volume to zero.\n"); // @formatter:on config.getConfiguration().options().copyHeader(); @@ -57,7 +54,13 @@ public void reload(boolean save) { try { reloadSound(sound); } catch (Exception | LinkageError x) { - Slimefun.logger().log(Level.SEVERE, x, () -> "An exception was thrown while trying to load the configuration data for the following sound:" + sound.name()); + Slimefun.logger() + .log( + Level.SEVERE, + x, + () -> "An exception was thrown while trying to load the configuration data for the" + + " following sound:" + + sound.name()); } } @@ -79,13 +82,21 @@ private void reloadSound(@Nonnull SoundEffect sound) { // Check whether the volume is at least 0.0 if (volume < 0) { - Slimefun.logger().log(Level.WARNING, "Invalid value in sounds.yml! Volume for Sound \"{0}\" was {1} (must be at least 0.0)", new Object[] { sound.name(), volume }); + Slimefun.logger() + .log( + Level.WARNING, + "Invalid value in sounds.yml! Volume for Sound \"{0}\" was {1} (must be at least" + " 0.0)", + new Object[] {sound.name(), volume}); volume = 0; } // Check if the pitch is at least 0.5 if (pitch < 0.5F) { - Slimefun.logger().log(Level.WARNING, "Invalid value in sounds.yml! Pitch for Sound \"{0}\" was {1} (must be at least 0.5)", new Object[] { sound.name(), pitch }); + Slimefun.logger() + .log( + Level.WARNING, + "Invalid value in sounds.yml! Pitch for Sound \"{0}\" was {1} (must be at least 0.5)", + new Object[] {sound.name(), pitch}); pitch = 0.5F; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java index c14c511439..e67c903fd5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/sounds/package-info.java @@ -4,4 +4,4 @@ * This service is responsible for our sound management and allowing server owners to fully customize * their sound experience. */ -package io.github.thebusybiscuit.slimefun4.core.services.sounds; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.core.services.sounds; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java index c05ab68408..c7020b521b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/Slimefun.java @@ -178,7 +178,8 @@ public final class Slimefun extends JavaPlugin implements SlimefunAddon, ICompat private final BlockDataService blockDataService = new BlockDataService(this, "slimefun_block"); private final CustomTextureService textureService = new CustomTextureService(new Config(this, "item-models.yml")); private final GitHubService gitHubService = new GitHubService("StarWishsama/Slimefun4"); - private final UpdaterService updaterService = new UpdaterService(this, getDescription().getVersion(), getFile()); + private final UpdaterService updaterService = + new UpdaterService(this, getDescription().getVersion(), getFile()); private final MetricsService metricsService = new MetricsService(this); private final AutoSavingService autoSavingService = new AutoSavingService(); private final BackupService backupService = new BackupService(); @@ -247,7 +248,8 @@ public void onEnable() { // We wanna ensure that the Server uses a compatible version of Minecraft. getServer().getPluginManager().disablePlugin(this); } else if (!SlimefunExtended.checkEnvironment(this)) { - // We want to ensure that the Server uses a compatible server software and have no incompatible plugins + // We want to ensure that the Server uses a compatible server software and have no + // incompatible plugins getServer().getPluginManager().disablePlugin(this); } else { // The Environment has been validated. @@ -294,7 +296,8 @@ private void onPluginStart() { StartupWarnings.oldJavaVersion(logger, RECOMMENDED_JAVA_VERSION); } - // If the server has no "data-storage" folder, it's _probably_ a new install. So mark it for metrics. + // If the server has no "data-storage" folder, it's _probably_ a new install. So mark it for + // metrics. isNewlyInstalled = !new File("data-storage/Slimefun").exists(); // Creating all necessary Folders @@ -306,7 +309,8 @@ private void onPluginStart() { registry.load(this); logger.log(Level.INFO, "正在加载数据库..."); - if (PlayerProfileMigrator.getInstance().hasOldData() || BlockStorageMigrator.getInstance().hasOldData()) { + if (PlayerProfileMigrator.getInstance().hasOldData() + || BlockStorageMigrator.getInstance().hasOldData()) { Slimefun.logger().warning("===================================================="); Slimefun.logger().warning("\n"); Slimefun.logger().log(Level.WARNING, "!!! 检测到使用文件储存的旧玩家数据 !!!"); @@ -336,7 +340,10 @@ private void onPluginStart() { networkSize = 1; } - networkManager = new NetworkManager(networkSize, config.getBoolean("networks.enable-visualizer"), config.getBoolean("networks.delete-excess-items")); + networkManager = new NetworkManager( + networkSize, + config.getBoolean("networks.enable-visualizer"), + config.getBoolean("networks.delete-excess-items")); // Setting up bStats new Thread(metricsService::start, "Slimefun Metrics").start(); @@ -360,20 +367,30 @@ private void onPluginStart() { logger.log(Level.INFO, "正在注册监听器..."); registerListeners(); - // Initiating various Stuff and all items with a slight delay (0ms after the Server finished loading) - runSync(new SlimefunStartupTask(this, () -> { - textureService.register(registry.getAllSlimefunItems(), true); - permissionsService.update(registry.getAllSlimefunItems(), true); - soundService.reload(true); - - // This try/catch should prevent buggy Spigot builds from blocking item loading - try { - recipeService.refresh(); - } catch (Exception | LinkageError x) { - logger.log(Level.SEVERE, x, () -> "An Exception occured while iterating through the Recipe list on Minecraft Version " + minecraftVersion.getName() + " (Slimefun v" + getVersion() + ")"); - } - - }), 0); + // Initiating various Stuff and all items with a slight delay (0ms after the Server finished + // loading) + runSync( + new SlimefunStartupTask(this, () -> { + textureService.register(registry.getAllSlimefunItems(), true); + permissionsService.update(registry.getAllSlimefunItems(), true); + soundService.reload(true); + + // This try/catch should prevent buggy Spigot builds from blocking item loading + try { + recipeService.refresh(); + } catch (Exception | LinkageError x) { + logger.log( + Level.SEVERE, + x, + () -> "An Exception occured while iterating through the Recipe list on Minecraft" + + " Version " + + minecraftVersion.getName() + + " (Slimefun v" + + getVersion() + + ")"); + } + }), + 0); // Setting up our commands try { @@ -445,7 +462,12 @@ public void onDisable() { ticker.halt(); ticker.run(); } catch (Exception x) { - getLogger().log(Level.SEVERE, x, () -> "Something went wrong while disabling the ticker task for Slimefun v" + getDescription().getVersion()); + getLogger() + .log( + Level.SEVERE, + x, + () -> "Something went wrong while disabling the ticker task for Slimefun v" + + getDescription().getVersion()); } // Kill our Profiler Threads @@ -555,7 +577,8 @@ private boolean isVersionUnsupported() { } // Looks like you are using an unsupported Minecraft Version - StartupWarnings.invalidMinecraftVersion(getLogger(), version, getDescription().getVersion()); + StartupWarnings.invalidMinecraftVersion( + getLogger(), version, getDescription().getVersion()); return true; } else { getLogger().log(Level.WARNING, "我们无法识别你正在使用的 Minecraft 版本 (1.{0}.x)", version); @@ -569,7 +592,12 @@ private boolean isVersionUnsupported() { return false; } } catch (Exception | LinkageError x) { - getLogger().log(Level.SEVERE, x, () -> "错误: 无法识别服务器 Minecraft 版本, Slimefun v" + getDescription().getVersion()); + getLogger() + .log( + Level.SEVERE, + x, + () -> "错误: 无法识别服务器 Minecraft 版本, Slimefun v" + + getDescription().getVersion()); // We assume "unsupported" if something went wrong. return true; @@ -592,8 +620,8 @@ private boolean isVersionUnsupported() { * This method creates all necessary directories (and sub directories) for Slimefun. */ private void createDirectories() { - String[] storageFolders = { "waypoints", "block-backups" }; - String[] pluginFolders = { "scripts", "error-reports", "cache/github", "world-settings" }; + String[] storageFolders = {"waypoints", "block-backups"}; + String[] pluginFolders = {"scripts", "error-reports", "cache/github", "world-settings"}; for (String folder : storageFolders) { File file = new File("data-storage/Slimefun", folder); @@ -670,7 +698,8 @@ private void registerListeners() { new CoolerListener(this, (Cooler) SlimefunItems.COOLER.getItem()); new SeismicAxeListener(this, (SeismicAxe) SlimefunItems.SEISMIC_AXE.getItem()); new RadioactivityListener(this); - new AncientAltarListener(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem(), (AncientPedestal) SlimefunItems.ANCIENT_PEDESTAL.getItem()); + new AncientAltarListener(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem(), (AncientPedestal) + SlimefunItems.ANCIENT_PEDESTAL.getItem()); grapplingHookListener.register(this, (GrapplingHook) SlimefunItems.GRAPPLING_HOOK.getItem()); bowListener.register(this); backpackListener.register(this); @@ -705,7 +734,11 @@ private void loadItems() { try { SlimefunItemSetup.setup(this); } catch (Exception | LinkageError x) { - getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing SlimefunItems for Slimefun " + getVersion()); + getLogger() + .log( + Level.SEVERE, + x, + () -> "An Error occurred while initializing SlimefunItems for Slimefun " + getVersion()); } } @@ -716,7 +749,12 @@ private void loadResearches() { try { ResearchSetup.setupResearches(); } catch (Exception | LinkageError x) { - getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing Slimefun Researches for Slimefun " + getVersion()); + getLogger() + .log( + Level.SEVERE, + x, + () -> "An Error occurred while initializing Slimefun Researches for Slimefun " + + getVersion()); } } @@ -877,7 +915,6 @@ public static SoundService getSoundService() { * * @return Our {@link NetworkManager} instance */ - public static @Nonnull NetworkManager getNetworkManager() { validateInstance(); return instance.networkManager; @@ -1027,25 +1064,28 @@ public static boolean isNewlyInstalled() { String pluginName = instance.getName(); // @formatter:off - Collect any Plugin that (soft)-depends on Slimefun - return Arrays.stream(instance.getServer().getPluginManager().getPlugins()).filter(plugin -> { - PluginDescriptionFile description = plugin.getDescription(); - return description.getDepend().contains(pluginName) || description.getSoftDepend().contains(pluginName); - }).collect(Collectors.toSet()); + return Arrays.stream(instance.getServer().getPluginManager().getPlugins()) + .filter(plugin -> { + PluginDescriptionFile description = plugin.getDescription(); + return description.getDepend().contains(pluginName) + || description.getSoftDepend().contains(pluginName); + }) + .collect(Collectors.toSet()); // @formatter:on } /** * This method schedules a delayed synchronous task for Slimefun. * For Slimefun only, not for addons. - * + * * This method should only be invoked by Slimefun itself. * Addons must schedule their own tasks using their own {@link Plugin} instance. - * + * * @param runnable * The {@link Runnable} to run * @param delay * The delay for this task - * + * * @return The resulting {@link BukkitTask} or null if Slimefun was disabled */ public static @Nullable BukkitTask runSync(@Nonnull Runnable runnable, long delay) { @@ -1068,13 +1108,13 @@ public static boolean isNewlyInstalled() { /** * This method schedules a synchronous task for Slimefun. * For Slimefun only, not for addons. - * + * * This method should only be invoked by Slimefun itself. * Addons must schedule their own tasks using their own {@link Plugin} instance. - * + * * @param runnable * The {@link Runnable} to run - * + * * @return The resulting {@link BukkitTask} or null if Slimefun was disabled */ public static @Nullable BukkitTask runSync(@Nonnull Runnable runnable) { @@ -1102,5 +1142,4 @@ public File getFile() { validateInstance(); return instance.chatCatcher; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index 853747bbfa..feeaebc62a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -30,81 +30,467 @@ @SuppressWarnings("java:S1192") // Suppress "duplicate string literal" warnings public final class SlimefunItems { - private SlimefunItems() { - } + private SlimefunItems() {} /* Items */ - public static final SlimefunItemStack PORTABLE_CRAFTER = new SlimefunItemStack("PORTABLE_CRAFTER", HeadTexture.PORTABLE_CRAFTER, "&6便携工作台", "&a&o一个便携式的工作台", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack PORTABLE_DUSTBIN = new SlimefunItemStack("PORTABLE_DUSTBIN", HeadTexture.TRASH_CAN, "&6便携垃圾箱", "&r轻松的消除多余的物品", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack ENDER_BACKPACK = new SlimefunItemStack("ENDER_BACKPACK", HeadTexture.ENDER_BACKPACK, "&6末影背包", "&a&o便携式末影箱", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack MAGIC_EYE_OF_ENDER = new SlimefunItemStack("MAGIC_EYE_OF_ENDER", Material.ENDER_EYE, "&6&l魔法末影之眼", "&4&l需要全套末影护甲", "", "&7&e右键&7 以射出一颗末影珍珠"); - public static final SlimefunItemStack BROKEN_SPAWNER = new SlimefunItemStack("BROKEN_SPAWNER", Material.SPAWNER, "&c已损坏的刷怪笼", "&7类型: &b<类型>", "", "&c已损坏, 需要在古代祭坛中修复"); - public static final SlimefunItemStack REPAIRED_SPAWNER = new SlimefunItemStack("REINFORCED_SPAWNER", Material.SPAWNER, "&b已修复的刷怪笼", "&7类型: &b<类型>"); - public static final SlimefunItemStack INFERNAL_BONEMEAL = new SlimefunItemStack("INFERNAL_BONEMEAL", Material.BONE_MEAL, "&4地狱骨粉", "", "&c加速地狱疣的生长速度"); - public static final SlimefunItemStack TAPE_MEASURE = new SlimefunItemStack("TAPE_MEASURE", "180d5c43a6cf5bb7769fd0c8240e1e70d2ae38ef9d78a1db401aca6a2cb36f65", "&6卷尺", "", "&eShift + 右键 &7设置测量起点", "&e右键 &7测量距离"); + public static final SlimefunItemStack PORTABLE_CRAFTER = new SlimefunItemStack( + "PORTABLE_CRAFTER", + HeadTexture.PORTABLE_CRAFTER, + "&6便携工作台", + "&a&o一个便携式的工作台", + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack PORTABLE_DUSTBIN = new SlimefunItemStack( + "PORTABLE_DUSTBIN", HeadTexture.TRASH_CAN, "&6便携垃圾箱", "&r轻松的消除多余的物品", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack ENDER_BACKPACK = new SlimefunItemStack( + "ENDER_BACKPACK", HeadTexture.ENDER_BACKPACK, "&6末影背包", "&a&o便携式末影箱", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack MAGIC_EYE_OF_ENDER = new SlimefunItemStack( + "MAGIC_EYE_OF_ENDER", Material.ENDER_EYE, "&6&l魔法末影之眼", "&4&l需要全套末影护甲", "", "&7&e右键&7 以射出一颗末影珍珠"); + public static final SlimefunItemStack BROKEN_SPAWNER = new SlimefunItemStack( + "BROKEN_SPAWNER", Material.SPAWNER, "&c已损坏的刷怪笼", "&7类型: &b<类型>", "", "&c已损坏, 需要在古代祭坛中修复"); + public static final SlimefunItemStack REPAIRED_SPAWNER = + new SlimefunItemStack("REINFORCED_SPAWNER", Material.SPAWNER, "&b已修复的刷怪笼", "&7类型: &b<类型>"); + public static final SlimefunItemStack INFERNAL_BONEMEAL = + new SlimefunItemStack("INFERNAL_BONEMEAL", Material.BONE_MEAL, "&4地狱骨粉", "", "&c加速地狱疣的生长速度"); + public static final SlimefunItemStack TAPE_MEASURE = new SlimefunItemStack( + "TAPE_MEASURE", + "180d5c43a6cf5bb7769fd0c8240e1e70d2ae38ef9d78a1db401aca6a2cb36f65", + "&6卷尺", + "", + "&eShift + 右键 &7设置测量起点", + "&e右键 &7测量距离"); /* Gadgets */ - public static final SlimefunItemStack GOLD_PAN = new SlimefunItemStack("GOLD_PAN", Material.BOWL, "&6淘金盘", "&a&o可以获得各种各样的矿物", "", "&7&e右键&7 从沙砾中淘金"); - public static final SlimefunItemStack NETHER_GOLD_PAN = new SlimefunItemStack("NETHER_GOLD_PAN", Material.BOWL, "&4下界淘金盘", "", "&7&e右键&7 从灵魂沙中淘金"); - public static final SlimefunItemStack PARACHUTE = new SlimefunItemStack("PARACHUTE", Material.LEATHER_CHESTPLATE, Color.WHITE, "&r&l降落伞", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack GRAPPLING_HOOK = new SlimefunItemStack("GRAPPLING_HOOK", Material.LEAD, "&6抓钩", "", LoreBuilder.RIGHT_CLICK_TO_USE); - public static final SlimefunItemStack SOLAR_HELMET = new SlimefunItemStack("SOLAR_HELMET", Material.IRON_HELMET, "&b太阳能头盔", "", "&a&o为你拿着的物品和装备充电"); + public static final SlimefunItemStack GOLD_PAN = + new SlimefunItemStack("GOLD_PAN", Material.BOWL, "&6淘金盘", "&a&o可以获得各种各样的矿物", "", "&7&e右键&7 从沙砾中淘金"); + public static final SlimefunItemStack NETHER_GOLD_PAN = + new SlimefunItemStack("NETHER_GOLD_PAN", Material.BOWL, "&4下界淘金盘", "", "&7&e右键&7 从灵魂沙中淘金"); + public static final SlimefunItemStack PARACHUTE = new SlimefunItemStack( + "PARACHUTE", Material.LEATHER_CHESTPLATE, Color.WHITE, "&r&l降落伞", "", LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack GRAPPLING_HOOK = + new SlimefunItemStack("GRAPPLING_HOOK", Material.LEAD, "&6抓钩", "", LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack SOLAR_HELMET = + new SlimefunItemStack("SOLAR_HELMET", Material.IRON_HELMET, "&b太阳能头盔", "", "&a&o为你拿着的物品和装备充电"); public static final SlimefunItemStack CLOTH = new SlimefunItemStack("CLOTH", Material.PAPER, "&b布"); - public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack("REINFORCED_CLOTH", Material.PAPER, "&b强化布料", "", "&f这种布在被铅强化过后", "&f可以防止放射物给你带来的负面影响"); + public static final SlimefunItemStack REINFORCED_CLOTH = new SlimefunItemStack( + "REINFORCED_CLOTH", Material.PAPER, "&b强化布料", "", "&f这种布在被铅强化过后", "&f可以防止放射物给你带来的负面影响"); public static final SlimefunItemStack TIN_CAN = new SlimefunItemStack("CAN", HeadTexture.TIN_CAN, "&r锡罐"); - public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack("NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&a夜视眼镜", "", "&9+ 夜视效果"); - public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack("ELYTRA_CAP", Material.LEATHER_HELMET, Color.PURPLE, "&5鞘翅帽", "", "&7能使你在用鞘翅飞行途中", "&7不会摔下来变成肉酱"); - public static final SlimefunItemStack FARMER_SHOES = new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&e农夫的靴子", "", "&6&o能够防止你踩坏农田"); - public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack("INFUSED_MAGNET", HeadTexture.MAGNET, "&a吸入磁铁", "", "&r注入了魔法的磁铁", "&r能够将附近的物品", "&r放入你的背包", "", "&7按住 &eShift&7 吸取周围的物品"); - public static final SlimefunItemStack RAG = new SlimefunItemStack("RAG", Material.PAPER, "&c破布", "", "&a1级医疗供给", "", "&r恢复2点血量", "&r可以熄灭身上的火", "", LoreBuilder.RIGHT_CLICK_TO_USE); - public static final SlimefunItemStack BANDAGE = new SlimefunItemStack("BANDAGE", Material.PAPER, "&c绷带", "", "&a2级医疗供给", "", "&r恢复4点血量", "&r可以熄灭身上的火", "", LoreBuilder.RIGHT_CLICK_TO_USE); - public static final SlimefunItemStack SPLINT = new SlimefunItemStack("SPLINT", Material.STICK, "&c夹板", "", "&a1级医疗供给", "", "&r恢复2点血量", "", LoreBuilder.RIGHT_CLICK_TO_USE); - public static final SlimefunItemStack VITAMINS = new SlimefunItemStack("VITAMINS", Material.NETHER_WART, "&c维他命", "", "&a3级医疗供给", "", "&r恢复4点血量", "&r可以熄灭身上的火", "&r治愈中毒/凋零/辐射的负面效果", "", LoreBuilder.RIGHT_CLICK_TO_USE); - public static final SlimefunItemStack MEDICINE = new SlimefunItemStack("MEDICINE", Material.POTION, Color.RED, "&c药物", "", "&a3级医疗供给", "", "&r恢复4点血量", "&r可以熄灭身上的火", "&r治愈中毒/凋零/辐射的负面效果", "", "&7&e右键&7 饮用"); - public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6还魂丹", "", "&e右键立即治愈 &7僵尸村民/猪灵"); - - public static final SlimefunItemStack FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FLASK_OF_KNOWLEDGE", Material.GLASS_BOTTLE, "&c学识之瓶", "", "&r允许你将经验储存在瓶子里", "&7需要消耗 &a1 个等级"); - public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", Material.EXPERIENCE_BOTTLE, "&a学识之瓶"); + public static final SlimefunItemStack NIGHT_VISION_GOGGLES = new SlimefunItemStack( + "NIGHT_VISION_GOGGLES", Material.LEATHER_HELMET, Color.BLACK, "&a夜视眼镜", "", "&9+ 夜视效果"); + public static final SlimefunItemStack ELYTRA_CAP = new SlimefunItemStack( + "ELYTRA_CAP", Material.LEATHER_HELMET, Color.PURPLE, "&5鞘翅帽", "", "&7能使你在用鞘翅飞行途中", "&7不会摔下来变成肉酱"); + public static final SlimefunItemStack FARMER_SHOES = + new SlimefunItemStack("FARMER_SHOES", Material.LEATHER_BOOTS, Color.YELLOW, "&e农夫的靴子", "", "&6&o能够防止你踩坏农田"); + public static final SlimefunItemStack INFUSED_MAGNET = new SlimefunItemStack( + "INFUSED_MAGNET", + HeadTexture.MAGNET, + "&a吸入磁铁", + "", + "&r注入了魔法的磁铁", + "&r能够将附近的物品", + "&r放入你的背包", + "", + "&7按住 &eShift&7 吸取周围的物品"); + public static final SlimefunItemStack RAG = new SlimefunItemStack( + "RAG", + Material.PAPER, + "&c破布", + "", + "&a1级医疗供给", + "", + "&r恢复2点血量", + "&r可以熄灭身上的火", + "", + LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack BANDAGE = new SlimefunItemStack( + "BANDAGE", + Material.PAPER, + "&c绷带", + "", + "&a2级医疗供给", + "", + "&r恢复4点血量", + "&r可以熄灭身上的火", + "", + LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack SPLINT = new SlimefunItemStack( + "SPLINT", Material.STICK, "&c夹板", "", "&a1级医疗供给", "", "&r恢复2点血量", "", LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack VITAMINS = new SlimefunItemStack( + "VITAMINS", + Material.NETHER_WART, + "&c维他命", + "", + "&a3级医疗供给", + "", + "&r恢复4点血量", + "&r可以熄灭身上的火", + "&r治愈中毒/凋零/辐射的负面效果", + "", + LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack MEDICINE = new SlimefunItemStack( + "MEDICINE", + Material.POTION, + Color.RED, + "&c药物", + "", + "&a3级医疗供给", + "", + "&r恢复4点血量", + "&r可以熄灭身上的火", + "&r治愈中毒/凋零/辐射的负面效果", + "", + "&7&e右键&7 饮用"); + public static final SlimefunItemStack MAGICAL_ZOMBIE_PILLS = + new SlimefunItemStack("MAGICAL_ZOMBIE_PILLS", Material.NETHER_WART, "&6还魂丹", "", "&e右键立即治愈 &7僵尸村民/猪灵"); + + public static final SlimefunItemStack FLASK_OF_KNOWLEDGE = new SlimefunItemStack( + "FLASK_OF_KNOWLEDGE", Material.GLASS_BOTTLE, "&c学识之瓶", "", "&r允许你将经验储存在瓶子里", "&7需要消耗 &a1 个等级"); + public static final SlimefunItemStack FILLED_FLASK_OF_KNOWLEDGE = + new SlimefunItemStack("FILLED_FLASK_OF_KNOWLEDGE", Material.EXPERIENCE_BOTTLE, "&a学识之瓶"); /* Backpacks */ - public static final SlimefunItemStack BACKPACK_SMALL = new SlimefunItemStack("SMALL_BACKPACK", HeadTexture.BACKPACK, "&e小型背包", "", "&7大小: &e9", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack BACKPACK_MEDIUM = new SlimefunItemStack("MEDIUM_BACKPACK", HeadTexture.BACKPACK, "&e普通背包", "", "&7大小: &e18", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack BACKPACK_LARGE = new SlimefunItemStack("LARGE_BACKPACK", HeadTexture.BACKPACK, "&e中型背包", "", "&7大小: &e27", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack WOVEN_BACKPACK = new SlimefunItemStack("WOVEN_BACKPACK", HeadTexture.BACKPACK, "&e编织背包", "", "&7大小: &e36", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack GILDED_BACKPACK = new SlimefunItemStack("GILDED_BACKPACK", HeadTexture.BACKPACK, "&e镀金背包", "", "&7大小: &e45", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack RADIANT_BACKPACK = new SlimefunItemStack("RADIANT_BACKPACK", HeadTexture.BACKPACK, "&e金光闪闪的背包", "", "&7大小: &e54 (大箱子)", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack BOUND_BACKPACK = new SlimefunItemStack("BOUND_BACKPACK", HeadTexture.ENDER_BACKPACK, "&c灵魂绑定背包", "", "&7大小: &e36", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack COOLER = new SlimefunItemStack("COOLER", HeadTexture.COOLER, "&b小冰柜", "&r可以储存果汁和冰沙", "&r当小冰柜在你的物品栏里时", "&r在你饥饿时将会自动消耗里面的食物", "", "&7大小: &e27", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack RESTORED_BACKPACK = new SlimefunItemStack("RESTORED_BACKPACK", HeadTexture.RESTORED_BACKPACK, "&e背包恢复器", "", "&7重新获取你丢失背包里的物品", PlayerBackpack.LORE_OWNER, "", LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack BACKPACK_SMALL = new SlimefunItemStack( + "SMALL_BACKPACK", + HeadTexture.BACKPACK, + "&e小型背包", + "", + "&7大小: &e9", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack BACKPACK_MEDIUM = new SlimefunItemStack( + "MEDIUM_BACKPACK", + HeadTexture.BACKPACK, + "&e普通背包", + "", + "&7大小: &e18", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack BACKPACK_LARGE = new SlimefunItemStack( + "LARGE_BACKPACK", + HeadTexture.BACKPACK, + "&e中型背包", + "", + "&7大小: &e27", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack WOVEN_BACKPACK = new SlimefunItemStack( + "WOVEN_BACKPACK", + HeadTexture.BACKPACK, + "&e编织背包", + "", + "&7大小: &e36", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack GILDED_BACKPACK = new SlimefunItemStack( + "GILDED_BACKPACK", + HeadTexture.BACKPACK, + "&e镀金背包", + "", + "&7大小: &e45", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack RADIANT_BACKPACK = new SlimefunItemStack( + "RADIANT_BACKPACK", + HeadTexture.BACKPACK, + "&e金光闪闪的背包", + "", + "&7大小: &e54 (大箱子)", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack BOUND_BACKPACK = new SlimefunItemStack( + "BOUND_BACKPACK", + HeadTexture.ENDER_BACKPACK, + "&c灵魂绑定背包", + "", + "&7大小: &e36", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack COOLER = new SlimefunItemStack( + "COOLER", + HeadTexture.COOLER, + "&b小冰柜", + "&r可以储存果汁和冰沙", + "&r当小冰柜在你的物品栏里时", + "&r在你饥饿时将会自动消耗里面的食物", + "", + "&7大小: &e27", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack RESTORED_BACKPACK = new SlimefunItemStack( + "RESTORED_BACKPACK", + HeadTexture.RESTORED_BACKPACK, + "&e背包恢复器", + "", + "&7重新获取你丢失背包里的物品", + PlayerBackpack.LORE_OWNER, + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); /* Jetpacks */ - public static final SlimefunItemStack DURALUMIN_JETPACK = new SlimefunItemStack("DURALUMIN_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9电力喷气背包 &7- &eI", "", LoreBuilder.material("硬铝"), LoreBuilder.powerCharged(0, 20), "&8\u21E8 &7推力: &c0.35", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack SOLDER_JETPACK = new SlimefunItemStack("SOLDER_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9电力喷气背包 &7- &eII", "", LoreBuilder.material("焊锡"), LoreBuilder.powerCharged(0, 30), "&8\u21E8 &7推力: &c0.4", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack BILLON_JETPACK = new SlimefunItemStack("BILLON_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9电力喷气背包 &7- &eIII", "", LoreBuilder.material("银铜合金"), LoreBuilder.powerCharged(0, 45), "&8\u21E8 &7推力: &c0.45", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack STEEL_JETPACK = new SlimefunItemStack("STEEL_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9电力喷气背包 &7- &eIV", "", LoreBuilder.material("钢"), LoreBuilder.powerCharged(0, 60), "&8\u21E8 &7推力: &c0.5", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack DAMASCUS_STEEL_JETPACK = new SlimefunItemStack("DAMASCUS_STEEL_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9电力喷气背包 &7- &eV", "", LoreBuilder.material("大马士革钢"), LoreBuilder.powerCharged(0, 75), "&8\u21E8 &7推力: &c0.55", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack REINFORCED_ALLOY_JETPACK = new SlimefunItemStack("REINFORCED_ALLOY_JETPACK", Material.LEATHER_CHESTPLATE, Color.SILVER, "&9电力喷气背包 &7- &eVI", "", LoreBuilder.material("强化合金"), LoreBuilder.powerCharged(0, 100), "&8\u21E8 &7推力: &c0.6", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack CARBONADO_JETPACK = new SlimefunItemStack("CARBONADO_JETPACK", Material.LEATHER_CHESTPLATE, Color.BLACK, "&9电力喷气背包 &7- &eVII", "", LoreBuilder.material("黑金刚石"), LoreBuilder.powerCharged(0, 150), "&8\u21E8 &7推力: &c0.7", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack ARMORED_JETPACK = new SlimefunItemStack("ARMORED_JETPACK", Material.IRON_CHESTPLATE, "&9装甲喷气背包", LoreBuilder.material("钢"), "", LoreBuilder.powerCharged(0, 50), "&8\u21E8 &7推力: &c0.5", "", LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack DURALUMIN_JETPACK = new SlimefunItemStack( + "DURALUMIN_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.SILVER, + "&9电力喷气背包 &7- &eI", + "", + LoreBuilder.material("硬铝"), + LoreBuilder.powerCharged(0, 20), + "&8\u21E8 &7推力: &c0.35", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack SOLDER_JETPACK = new SlimefunItemStack( + "SOLDER_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.SILVER, + "&9电力喷气背包 &7- &eII", + "", + LoreBuilder.material("焊锡"), + LoreBuilder.powerCharged(0, 30), + "&8\u21E8 &7推力: &c0.4", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack BILLON_JETPACK = new SlimefunItemStack( + "BILLON_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.SILVER, + "&9电力喷气背包 &7- &eIII", + "", + LoreBuilder.material("银铜合金"), + LoreBuilder.powerCharged(0, 45), + "&8\u21E8 &7推力: &c0.45", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack STEEL_JETPACK = new SlimefunItemStack( + "STEEL_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.SILVER, + "&9电力喷气背包 &7- &eIV", + "", + LoreBuilder.material("钢"), + LoreBuilder.powerCharged(0, 60), + "&8\u21E8 &7推力: &c0.5", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack DAMASCUS_STEEL_JETPACK = new SlimefunItemStack( + "DAMASCUS_STEEL_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.SILVER, + "&9电力喷气背包 &7- &eV", + "", + LoreBuilder.material("大马士革钢"), + LoreBuilder.powerCharged(0, 75), + "&8\u21E8 &7推力: &c0.55", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack REINFORCED_ALLOY_JETPACK = new SlimefunItemStack( + "REINFORCED_ALLOY_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.SILVER, + "&9电力喷气背包 &7- &eVI", + "", + LoreBuilder.material("强化合金"), + LoreBuilder.powerCharged(0, 100), + "&8\u21E8 &7推力: &c0.6", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack CARBONADO_JETPACK = new SlimefunItemStack( + "CARBONADO_JETPACK", + Material.LEATHER_CHESTPLATE, + Color.BLACK, + "&9电力喷气背包 &7- &eVII", + "", + LoreBuilder.material("黑金刚石"), + LoreBuilder.powerCharged(0, 150), + "&8\u21E8 &7推力: &c0.7", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack ARMORED_JETPACK = new SlimefunItemStack( + "ARMORED_JETPACK", + Material.IRON_CHESTPLATE, + "&9装甲喷气背包", + LoreBuilder.material("钢"), + "", + LoreBuilder.powerCharged(0, 50), + "&8\u21E8 &7推力: &c0.5", + "", + LoreBuilder.CROUCH_TO_USE); /* Jetboots */ - public static final SlimefunItemStack DURALUMIN_JETBOOTS = new SlimefunItemStack("DURALUMIN_JETBOOTS", Material.LEATHER_BOOTS, Color.SILVER, "&9喷气靴 &7- &eI", "", LoreBuilder.material("硬铝"), LoreBuilder.powerCharged(0, 20), "&8\u21E8 &7速度: &a0.35", "&8\u21E8 &7准确度: &c50%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack SOLDER_JETBOOTS = new SlimefunItemStack("SOLDER_JETBOOTS", Material.LEATHER_BOOTS, Color.SILVER, "&9喷气靴 &7- &eII", "", LoreBuilder.material("焊锡"), LoreBuilder.powerCharged(0, 30), "&8\u21E8 &7速度: &a0.4", "&8\u21E8 &7准确度: &660%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack BILLON_JETBOOTS = new SlimefunItemStack("BILLON_JETBOOTS", Material.LEATHER_BOOTS, Color.SILVER, "&9喷气靴 &7- &eIII", "", LoreBuilder.material("银铜合金"), LoreBuilder.powerCharged(0, 40), "&8\u21E8 &7速度: &a0.45", "&8\u21E8 &7准确度: &665%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack STEEL_JETBOOTS = new SlimefunItemStack("STEEL_JETBOOTS", Material.LEATHER_BOOTS, Color.SILVER, "&9喷气靴 &7- &eIV", "", LoreBuilder.material("钢"), LoreBuilder.powerCharged(0, 50), "&8\u21E8 &7速度: &a0.5", "&8\u21E8 &7准确度: &e70%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack DAMASCUS_STEEL_JETBOOTS = new SlimefunItemStack("DAMASCUS_STEEL_JETBOOTS", Material.LEATHER_BOOTS, Color.SILVER, "&9喷气靴 &7- &eV", "", LoreBuilder.material("大马士革钢"), LoreBuilder.powerCharged(0, 75), "&8\u21E8 &7速度: &a0.55", "&8\u21E8 &7准确度: &a75%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack REINFORCED_ALLOY_JETBOOTS = new SlimefunItemStack("REINFORCED_ALLOY_JETBOOTS", Material.LEATHER_BOOTS, Color.SILVER, "&9喷气靴 &7- &eVI", "", LoreBuilder.material("强化合金"), LoreBuilder.powerCharged(0, 100), "&8\u21E8 &7速度: &a0.6", "&8\u21E8 &7准确度: &c80%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack CARBONADO_JETBOOTS = new SlimefunItemStack("CARBONADO_JETBOOTS", Material.LEATHER_BOOTS, Color.BLACK, "&9喷气靴 &7- &eVII", "", LoreBuilder.material("黑金刚石"), LoreBuilder.powerCharged(0, 125), "&8\u21E8 &7速度: &a0.7", "&8\u21E8 &7准确度: &c99.9%", "", LoreBuilder.CROUCH_TO_USE); - public static final SlimefunItemStack ARMORED_JETBOOTS = new SlimefunItemStack("ARMORED_JETBOOTS", Material.IRON_BOOTS, "&9装甲喷气靴", "", LoreBuilder.material("钢"), LoreBuilder.powerCharged(0, 50), "&8\u21E8 &7速度: &a0.45", "&8\u21E8 &7准确度: &e70%", "", LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack DURALUMIN_JETBOOTS = new SlimefunItemStack( + "DURALUMIN_JETBOOTS", + Material.LEATHER_BOOTS, + Color.SILVER, + "&9喷气靴 &7- &eI", + "", + LoreBuilder.material("硬铝"), + LoreBuilder.powerCharged(0, 20), + "&8\u21E8 &7速度: &a0.35", + "&8\u21E8 &7准确度: &c50%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack SOLDER_JETBOOTS = new SlimefunItemStack( + "SOLDER_JETBOOTS", + Material.LEATHER_BOOTS, + Color.SILVER, + "&9喷气靴 &7- &eII", + "", + LoreBuilder.material("焊锡"), + LoreBuilder.powerCharged(0, 30), + "&8\u21E8 &7速度: &a0.4", + "&8\u21E8 &7准确度: &660%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack BILLON_JETBOOTS = new SlimefunItemStack( + "BILLON_JETBOOTS", + Material.LEATHER_BOOTS, + Color.SILVER, + "&9喷气靴 &7- &eIII", + "", + LoreBuilder.material("银铜合金"), + LoreBuilder.powerCharged(0, 40), + "&8\u21E8 &7速度: &a0.45", + "&8\u21E8 &7准确度: &665%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack STEEL_JETBOOTS = new SlimefunItemStack( + "STEEL_JETBOOTS", + Material.LEATHER_BOOTS, + Color.SILVER, + "&9喷气靴 &7- &eIV", + "", + LoreBuilder.material("钢"), + LoreBuilder.powerCharged(0, 50), + "&8\u21E8 &7速度: &a0.5", + "&8\u21E8 &7准确度: &e70%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack DAMASCUS_STEEL_JETBOOTS = new SlimefunItemStack( + "DAMASCUS_STEEL_JETBOOTS", + Material.LEATHER_BOOTS, + Color.SILVER, + "&9喷气靴 &7- &eV", + "", + LoreBuilder.material("大马士革钢"), + LoreBuilder.powerCharged(0, 75), + "&8\u21E8 &7速度: &a0.55", + "&8\u21E8 &7准确度: &a75%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack REINFORCED_ALLOY_JETBOOTS = new SlimefunItemStack( + "REINFORCED_ALLOY_JETBOOTS", + Material.LEATHER_BOOTS, + Color.SILVER, + "&9喷气靴 &7- &eVI", + "", + LoreBuilder.material("强化合金"), + LoreBuilder.powerCharged(0, 100), + "&8\u21E8 &7速度: &a0.6", + "&8\u21E8 &7准确度: &c80%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack CARBONADO_JETBOOTS = new SlimefunItemStack( + "CARBONADO_JETBOOTS", + Material.LEATHER_BOOTS, + Color.BLACK, + "&9喷气靴 &7- &eVII", + "", + LoreBuilder.material("黑金刚石"), + LoreBuilder.powerCharged(0, 125), + "&8\u21E8 &7速度: &a0.7", + "&8\u21E8 &7准确度: &c99.9%", + "", + LoreBuilder.CROUCH_TO_USE); + public static final SlimefunItemStack ARMORED_JETBOOTS = new SlimefunItemStack( + "ARMORED_JETBOOTS", + Material.IRON_BOOTS, + "&9装甲喷气靴", + "", + LoreBuilder.material("钢"), + LoreBuilder.powerCharged(0, 50), + "&8\u21E8 &7速度: &a0.45", + "&8\u21E8 &7准确度: &e70%", + "", + LoreBuilder.CROUCH_TO_USE); /* Multi Tools */ - public static final SlimefunItemStack DURALUMIN_MULTI_TOOL = new SlimefunItemStack("DURALUMIN_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eI", "", LoreBuilder.material("硬铝"), LoreBuilder.powerCharged(0, 20), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); - public static final SlimefunItemStack SOLDER_MULTI_TOOL = new SlimefunItemStack("SOLDER_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eII", "", LoreBuilder.material("焊锡"), LoreBuilder.powerCharged(0, 30), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); - public static final SlimefunItemStack BILLON_MULTI_TOOL = new SlimefunItemStack("BILLON_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eIII", "", LoreBuilder.material("银铜合金"), LoreBuilder.powerCharged(0, 40), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); - public static final SlimefunItemStack STEEL_MULTI_TOOL = new SlimefunItemStack("STEEL_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eIV", "", LoreBuilder.material("钢"), LoreBuilder.powerCharged(0, 50), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); - public static final SlimefunItemStack DAMASCUS_STEEL_MULTI_TOOL = new SlimefunItemStack("DAMASCUS_STEEL_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eV", "", LoreBuilder.material("大马士革钢"), LoreBuilder.powerCharged(0, 60), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); - public static final SlimefunItemStack REINFORCED_ALLOY_MULTI_TOOL = new SlimefunItemStack("REINFORCED_ALLOY_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eVI", "", LoreBuilder.material("强化合金"), LoreBuilder.powerCharged(0, 75), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); - public static final SlimefunItemStack CARBONADO_MULTI_TOOL = new SlimefunItemStack("CARBONADO_MULTI_TOOL", Material.SHEARS, "&9多功能工具 &7- &eVII", "", LoreBuilder.material("黑金刚石"), LoreBuilder.powerCharged(0, 100), "", LoreBuilder.RIGHT_CLICK_TO_USE, "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack DURALUMIN_MULTI_TOOL = new SlimefunItemStack( + "DURALUMIN_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eI", + "", + LoreBuilder.material("硬铝"), + LoreBuilder.powerCharged(0, 20), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack SOLDER_MULTI_TOOL = new SlimefunItemStack( + "SOLDER_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eII", + "", + LoreBuilder.material("焊锡"), + LoreBuilder.powerCharged(0, 30), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack BILLON_MULTI_TOOL = new SlimefunItemStack( + "BILLON_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eIII", + "", + LoreBuilder.material("银铜合金"), + LoreBuilder.powerCharged(0, 40), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack STEEL_MULTI_TOOL = new SlimefunItemStack( + "STEEL_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eIV", + "", + LoreBuilder.material("钢"), + LoreBuilder.powerCharged(0, 50), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack DAMASCUS_STEEL_MULTI_TOOL = new SlimefunItemStack( + "DAMASCUS_STEEL_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eV", + "", + LoreBuilder.material("大马士革钢"), + LoreBuilder.powerCharged(0, 60), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack REINFORCED_ALLOY_MULTI_TOOL = new SlimefunItemStack( + "REINFORCED_ALLOY_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eVI", + "", + LoreBuilder.material("强化合金"), + LoreBuilder.powerCharged(0, 75), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); + public static final SlimefunItemStack CARBONADO_MULTI_TOOL = new SlimefunItemStack( + "CARBONADO_MULTI_TOOL", + Material.SHEARS, + "&9多功能工具 &7- &eVII", + "", + LoreBuilder.material("黑金刚石"), + LoreBuilder.powerCharged(0, 100), + "", + LoreBuilder.RIGHT_CLICK_TO_USE, + "&7按住 &eShift + 右键&7 以更改模式"); static { ItemMeta duralumin = DURALUMIN_MULTI_TOOL.getItemMeta(); @@ -137,52 +523,151 @@ private SlimefunItems() { } /* Food */ - public static final SlimefunItemStack FORTUNE_COOKIE = new SlimefunItemStack("FORTUNE_COOKIE", Material.COOKIE, "&6幸运饼干", "", "&a&o告诉你未来发生的事 :o"); - public static final SlimefunItemStack DIET_COOKIE = new SlimefunItemStack("DIET_COOKIE", Material.COOKIE, "&6减肥曲奇", "", "&a一个非常&o轻&r&a的曲奇"); - public static final SlimefunItemStack MAGIC_SUGAR = new SlimefunItemStack("MAGIC_SUGAR", Material.SUGAR, "&6魔法糖", "", "&a&o感受赫尔墨斯的力量!"); - public static final SlimefunItemStack MONSTER_JERKY = new SlimefunItemStack("MONSTER_JERKY", Material.ROTTEN_FLESH, "&6怪物肉干", "", "&a&o提神抗饥饿"); - public static final SlimefunItemStack APPLE_JUICE = new SlimefunItemStack("APPLE_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&c苹果汁", "", LoreBuilder.hunger(3)); - public static final SlimefunItemStack MELON_JUICE = new SlimefunItemStack("MELON_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&c西瓜汁", "", LoreBuilder.hunger(3)); - public static final SlimefunItemStack CARROT_JUICE = new SlimefunItemStack("CARROT_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&6胡萝卜汁", "", LoreBuilder.hunger(3)); - public static final SlimefunItemStack PUMPKIN_JUICE = new SlimefunItemStack("PUMPKIN_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&6南瓜汁", "", LoreBuilder.hunger(3)); - public static final SlimefunItemStack SWEET_BERRY_JUICE = new SlimefunItemStack("SWEET_BERRY_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&c浆果汁", "", LoreBuilder.hunger(3)); - public static final SlimefunItemStack GLOW_BERRY_JUICE = new SlimefunItemStack("GLOW_BERRY_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&6发光浆果汁", "", LoreBuilder.hunger(3)); - public static final SlimefunItemStack GOLDEN_APPLE_JUICE = new SlimefunItemStack("GOLDEN_APPLE_JUICE", Color.YELLOW, new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 0), "&b金苹果汁"); - - public static final SlimefunItemStack BEEF_JERKY = new SlimefunItemStack("BEEF_JERKY", Material.COOKED_BEEF, "&6牛肉干", "", "&r横扫饥饿!"); - public static final SlimefunItemStack PORK_JERKY = new SlimefunItemStack("PORK_JERKY", Material.COOKED_PORKCHOP, "&6猪肉干", "", "&r横扫饥饿!"); - public static final SlimefunItemStack CHICKEN_JERKY = new SlimefunItemStack("CHICKEN_JERKY", Material.COOKED_CHICKEN, "&6鸡肉干", "", "&r横扫饥饿!"); - public static final SlimefunItemStack MUTTON_JERKY = new SlimefunItemStack("MUTTON_JERKY", Material.COOKED_MUTTON, "&6羊肉干", "", "&r横扫饥饿!"); - public static final SlimefunItemStack RABBIT_JERKY = new SlimefunItemStack("RABBIT_JERKY", Material.COOKED_RABBIT, "&6兔肉干", "", "&r横扫饥饿!"); - public static final SlimefunItemStack FISH_JERKY = new SlimefunItemStack("FISH_JERKY", Material.COOKED_COD, "&6鱼干", "", "&r横扫饥饿!"); + public static final SlimefunItemStack FORTUNE_COOKIE = + new SlimefunItemStack("FORTUNE_COOKIE", Material.COOKIE, "&6幸运饼干", "", "&a&o告诉你未来发生的事 :o"); + public static final SlimefunItemStack DIET_COOKIE = + new SlimefunItemStack("DIET_COOKIE", Material.COOKIE, "&6减肥曲奇", "", "&a一个非常&o轻&r&a的曲奇"); + public static final SlimefunItemStack MAGIC_SUGAR = + new SlimefunItemStack("MAGIC_SUGAR", Material.SUGAR, "&6魔法糖", "", "&a&o感受赫尔墨斯的力量!"); + public static final SlimefunItemStack MONSTER_JERKY = + new SlimefunItemStack("MONSTER_JERKY", Material.ROTTEN_FLESH, "&6怪物肉干", "", "&a&o提神抗饥饿"); + public static final SlimefunItemStack APPLE_JUICE = new SlimefunItemStack( + "APPLE_JUICE", + Color.RED, + new PotionEffect(PotionEffectType.SATURATION, 5, 0), + "&c苹果汁", + "", + LoreBuilder.hunger(3)); + public static final SlimefunItemStack MELON_JUICE = new SlimefunItemStack( + "MELON_JUICE", + Color.RED, + new PotionEffect(PotionEffectType.SATURATION, 5, 0), + "&c西瓜汁", + "", + LoreBuilder.hunger(3)); + public static final SlimefunItemStack CARROT_JUICE = new SlimefunItemStack( + "CARROT_JUICE", + Color.ORANGE, + new PotionEffect(PotionEffectType.SATURATION, 5, 0), + "&6胡萝卜汁", + "", + LoreBuilder.hunger(3)); + public static final SlimefunItemStack PUMPKIN_JUICE = new SlimefunItemStack( + "PUMPKIN_JUICE", + Color.ORANGE, + new PotionEffect(PotionEffectType.SATURATION, 5, 0), + "&6南瓜汁", + "", + LoreBuilder.hunger(3)); + public static final SlimefunItemStack SWEET_BERRY_JUICE = new SlimefunItemStack( + "SWEET_BERRY_JUICE", + Color.RED, + new PotionEffect(PotionEffectType.SATURATION, 5, 0), + "&c浆果汁", + "", + LoreBuilder.hunger(3)); + public static final SlimefunItemStack GLOW_BERRY_JUICE = new SlimefunItemStack( + "GLOW_BERRY_JUICE", + Color.ORANGE, + new PotionEffect(PotionEffectType.SATURATION, 5, 0), + "&6发光浆果汁", + "", + LoreBuilder.hunger(3)); + public static final SlimefunItemStack GOLDEN_APPLE_JUICE = new SlimefunItemStack( + "GOLDEN_APPLE_JUICE", Color.YELLOW, new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 0), "&b金苹果汁"); + + public static final SlimefunItemStack BEEF_JERKY = + new SlimefunItemStack("BEEF_JERKY", Material.COOKED_BEEF, "&6牛肉干", "", "&r横扫饥饿!"); + public static final SlimefunItemStack PORK_JERKY = + new SlimefunItemStack("PORK_JERKY", Material.COOKED_PORKCHOP, "&6猪肉干", "", "&r横扫饥饿!"); + public static final SlimefunItemStack CHICKEN_JERKY = + new SlimefunItemStack("CHICKEN_JERKY", Material.COOKED_CHICKEN, "&6鸡肉干", "", "&r横扫饥饿!"); + public static final SlimefunItemStack MUTTON_JERKY = + new SlimefunItemStack("MUTTON_JERKY", Material.COOKED_MUTTON, "&6羊肉干", "", "&r横扫饥饿!"); + public static final SlimefunItemStack RABBIT_JERKY = + new SlimefunItemStack("RABBIT_JERKY", Material.COOKED_RABBIT, "&6兔肉干", "", "&r横扫饥饿!"); + public static final SlimefunItemStack FISH_JERKY = + new SlimefunItemStack("FISH_JERKY", Material.COOKED_COD, "&6鱼干", "", "&r横扫饥饿!"); public static final SlimefunItemStack KELP_COOKIE = new SlimefunItemStack("KELP_COOKIE", Material.COOKIE, "&2海带曲奇"); /* Christmas */ - public static final SlimefunItemStack CHRISTMAS_MILK = new SlimefunItemStack("CHRISTMAS_MILK", Color.WHITE, new PotionEffect(PotionEffectType.SATURATION, 4, 0), "&6一杯牛奶", "", LoreBuilder.hunger(2.5)); - public static final SlimefunItemStack CHRISTMAS_CHOCOLATE_MILK = new SlimefunItemStack("CHRISTMAS_CHOCOLATE_MILK", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 11, 0), "&6巧克力牛奶", "", LoreBuilder.hunger(3.5)); - public static final SlimefunItemStack CHRISTMAS_EGG_NOG = new SlimefunItemStack("CHRISTMAS_EGG_NOG", Color.GRAY, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&a蛋酒", "", LoreBuilder.hunger(7)); - public static final SlimefunItemStack CHRISTMAS_APPLE_CIDER = new SlimefunItemStack("CHRISTMAS_APPLE_CIDER", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 13, 0), "&c苹果酒", "", LoreBuilder.hunger(7)); - public static final SlimefunItemStack CHRISTMAS_COOKIE = new SlimefunItemStack("CHRISTMAS_COOKIE", Material.COOKIE, ChatUtils.christmas("圣诞曲奇")); - public static final SlimefunItemStack CHRISTMAS_FRUIT_CAKE = new SlimefunItemStack("CHRISTMAS_FRUIT_CAKE", Material.PUMPKIN_PIE, ChatUtils.christmas("水果蛋糕")); - public static final SlimefunItemStack CHRISTMAS_APPLE_PIE = new SlimefunItemStack("CHRISTMAS_APPLE_PIE", Material.PUMPKIN_PIE, "&r苹果派"); - public static final SlimefunItemStack CHRISTMAS_HOT_CHOCOLATE = new SlimefunItemStack("CHRISTMAS_HOT_CHOCOLATE", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 13, 0), "&6热可可", "", LoreBuilder.hunger(7)); - public static final SlimefunItemStack CHRISTMAS_CAKE = new SlimefunItemStack("CHRISTMAS_CAKE", Material.PUMPKIN_PIE, ChatUtils.christmas("圣诞蛋糕")); - public static final SlimefunItemStack CHRISTMAS_CARAMEL = new SlimefunItemStack("CHRISTMAS_CARAMEL", Material.BRICK, "&6焦糖"); - public static final SlimefunItemStack CHRISTMAS_CARAMEL_APPLE = new SlimefunItemStack("CHRISTMAS_CARAMEL_APPLE", Material.APPLE, "&6焦糖苹果"); - public static final SlimefunItemStack CHRISTMAS_CHOCOLATE_APPLE = new SlimefunItemStack("CHRISTMAS_CHOCOLATE_APPLE", Material.APPLE, "&6巧克力苹果"); - public static final SlimefunItemStack CHRISTMAS_PRESENT = new SlimefunItemStack("CHRISTMAS_PRESENT", HeadTexture.CHRISTMAS_PRESENT, ChatUtils.christmas("圣诞礼物"), "&7来自 &eTheBusyBiscuit &7的礼物", "&7收件人: &e你", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack CHRISTMAS_MILK = new SlimefunItemStack( + "CHRISTMAS_MILK", + Color.WHITE, + new PotionEffect(PotionEffectType.SATURATION, 4, 0), + "&6一杯牛奶", + "", + LoreBuilder.hunger(2.5)); + public static final SlimefunItemStack CHRISTMAS_CHOCOLATE_MILK = new SlimefunItemStack( + "CHRISTMAS_CHOCOLATE_MILK", + Color.MAROON, + new PotionEffect(PotionEffectType.SATURATION, 11, 0), + "&6巧克力牛奶", + "", + LoreBuilder.hunger(3.5)); + public static final SlimefunItemStack CHRISTMAS_EGG_NOG = new SlimefunItemStack( + "CHRISTMAS_EGG_NOG", + Color.GRAY, + new PotionEffect(PotionEffectType.SATURATION, 6, 0), + "&a蛋酒", + "", + LoreBuilder.hunger(7)); + public static final SlimefunItemStack CHRISTMAS_APPLE_CIDER = new SlimefunItemStack( + "CHRISTMAS_APPLE_CIDER", + Color.RED, + new PotionEffect(PotionEffectType.SATURATION, 13, 0), + "&c苹果酒", + "", + LoreBuilder.hunger(7)); + public static final SlimefunItemStack CHRISTMAS_COOKIE = + new SlimefunItemStack("CHRISTMAS_COOKIE", Material.COOKIE, ChatUtils.christmas("圣诞曲奇")); + public static final SlimefunItemStack CHRISTMAS_FRUIT_CAKE = + new SlimefunItemStack("CHRISTMAS_FRUIT_CAKE", Material.PUMPKIN_PIE, ChatUtils.christmas("水果蛋糕")); + public static final SlimefunItemStack CHRISTMAS_APPLE_PIE = + new SlimefunItemStack("CHRISTMAS_APPLE_PIE", Material.PUMPKIN_PIE, "&r苹果派"); + public static final SlimefunItemStack CHRISTMAS_HOT_CHOCOLATE = new SlimefunItemStack( + "CHRISTMAS_HOT_CHOCOLATE", + Color.MAROON, + new PotionEffect(PotionEffectType.SATURATION, 13, 0), + "&6热可可", + "", + LoreBuilder.hunger(7)); + public static final SlimefunItemStack CHRISTMAS_CAKE = + new SlimefunItemStack("CHRISTMAS_CAKE", Material.PUMPKIN_PIE, ChatUtils.christmas("圣诞蛋糕")); + public static final SlimefunItemStack CHRISTMAS_CARAMEL = + new SlimefunItemStack("CHRISTMAS_CARAMEL", Material.BRICK, "&6焦糖"); + public static final SlimefunItemStack CHRISTMAS_CARAMEL_APPLE = + new SlimefunItemStack("CHRISTMAS_CARAMEL_APPLE", Material.APPLE, "&6焦糖苹果"); + public static final SlimefunItemStack CHRISTMAS_CHOCOLATE_APPLE = + new SlimefunItemStack("CHRISTMAS_CHOCOLATE_APPLE", Material.APPLE, "&6巧克力苹果"); + public static final SlimefunItemStack CHRISTMAS_PRESENT = new SlimefunItemStack( + "CHRISTMAS_PRESENT", + HeadTexture.CHRISTMAS_PRESENT, + ChatUtils.christmas("圣诞礼物"), + "&7来自 &eTheBusyBiscuit &7的礼物", + "&7收件人: &e你", + "", + LoreBuilder.RIGHT_CLICK_TO_OPEN); /* Easter */ - public static final SlimefunItemStack EASTER_EGG = new SlimefunItemStack("EASTER_EGG", HeadTexture.EASTER_EGG, "&r复活节彩蛋", "&d复活节快乐! 拆开礼物看看吧.", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); - public static final SlimefunItemStack EASTER_CARROT_PIE = new SlimefunItemStack("CARROT_PIE", Material.PUMPKIN_PIE, "&6胡萝卜派"); - public static final SlimefunItemStack EASTER_APPLE_PIE = new SlimefunItemStack("EASTER_APPLE_PIE", Material.PUMPKIN_PIE, "&r苹果派"); + public static final SlimefunItemStack EASTER_EGG = new SlimefunItemStack( + "EASTER_EGG", HeadTexture.EASTER_EGG, "&r复活节彩蛋", "&d复活节快乐! 拆开礼物看看吧.", "", LoreBuilder.RIGHT_CLICK_TO_OPEN); + public static final SlimefunItemStack EASTER_CARROT_PIE = + new SlimefunItemStack("CARROT_PIE", Material.PUMPKIN_PIE, "&6胡萝卜派"); + public static final SlimefunItemStack EASTER_APPLE_PIE = + new SlimefunItemStack("EASTER_APPLE_PIE", Material.PUMPKIN_PIE, "&r苹果派"); /* Weapons */ - public static final SlimefunItemStack GRANDMAS_WALKING_STICK = new SlimefunItemStack("GRANDMAS_WALKING_STICK", Material.STICK, "&7奶奶的拐杖"); - public static final SlimefunItemStack GRANDPAS_WALKING_STICK = new SlimefunItemStack("GRANDPAS_WALKING_STICK", Material.STICK, "&7爷爷的拐杖"); - public static final SlimefunItemStack SWORD_OF_BEHEADING = new SlimefunItemStack("SWORD_OF_BEHEADING", Material.IRON_SWORD, "&6处决之剑", "&7斩首处决 II", "", "&r有几率砍下生物的头", "&r(提高掉落凋灵骷髅头的几率)"); - public static final SlimefunItemStack BLADE_OF_VAMPIRES = new SlimefunItemStack("BLADE_OF_VAMPIRES", Material.GOLDEN_SWORD, "&c吸血鬼之刀", "&7生命窃取 I", "", "&r在攻击时有 45% 的几率", "使自己恢复 2 点血量"); - public static final SlimefunItemStack SEISMIC_AXE = new SlimefunItemStack("SEISMIC_AXE", Material.IRON_AXE, "&a地震斧", "", "&7&o制造一场地震...", "", LoreBuilder.RIGHT_CLICK_TO_USE); + public static final SlimefunItemStack GRANDMAS_WALKING_STICK = + new SlimefunItemStack("GRANDMAS_WALKING_STICK", Material.STICK, "&7奶奶的拐杖"); + public static final SlimefunItemStack GRANDPAS_WALKING_STICK = + new SlimefunItemStack("GRANDPAS_WALKING_STICK", Material.STICK, "&7爷爷的拐杖"); + public static final SlimefunItemStack SWORD_OF_BEHEADING = new SlimefunItemStack( + "SWORD_OF_BEHEADING", Material.IRON_SWORD, "&6处决之剑", "&7斩首处决 II", "", "&r有几率砍下生物的头", "&r(提高掉落凋灵骷髅头的几率)"); + public static final SlimefunItemStack BLADE_OF_VAMPIRES = new SlimefunItemStack( + "BLADE_OF_VAMPIRES", Material.GOLDEN_SWORD, "&c吸血鬼之刀", "&7生命窃取 I", "", "&r在攻击时有 45% 的几率", "使自己恢复 2 点血量"); + public static final SlimefunItemStack SEISMIC_AXE = new SlimefunItemStack( + "SEISMIC_AXE", Material.IRON_AXE, "&a地震斧", "", "&7&o制造一场地震...", "", LoreBuilder.RIGHT_CLICK_TO_USE); static { GRANDMAS_WALKING_STICK.addUnsafeEnchantment(Enchantment.KNOCKBACK, 2); @@ -194,19 +679,36 @@ private SlimefunItems() { } /* Bows */ - public static final SlimefunItemStack EXPLOSIVE_BOW = new SlimefunItemStack("EXPLOSIVE_BOW", Material.BOW, "&c爆裂之弓", "&r被爆裂之弓射出的箭击中将会飞上天"); - public static final SlimefunItemStack ICY_BOW = new SlimefunItemStack("ICY_BOW", Material.BOW, "&b冰封之弓", "&r被此弓射出的箭击中", "&r将会因寒冷而无法移动 (2秒内)"); + public static final SlimefunItemStack EXPLOSIVE_BOW = + new SlimefunItemStack("EXPLOSIVE_BOW", Material.BOW, "&c爆裂之弓", "&r被爆裂之弓射出的箭击中将会飞上天"); + public static final SlimefunItemStack ICY_BOW = + new SlimefunItemStack("ICY_BOW", Material.BOW, "&b冰封之弓", "&r被此弓射出的箭击中", "&r将会因寒冷而无法移动 (2秒内)"); /* Tools */ - public static final SlimefunItemStack SMELTERS_PICKAXE = new SlimefunItemStack("SMELTERS_PICKAXE", Material.DIAMOND_PICKAXE, "&6熔炉镐", "&c&l自动熔炼", "", "&9在挖矿时有时运效果"); - public static final SlimefunItemStack LUMBER_AXE = new SlimefunItemStack("LUMBER_AXE", Material.DIAMOND_AXE, "&6伐木斧", "&a&o砍倒整棵树木..."); - public static final SlimefunItemStack PICKAXE_OF_CONTAINMENT = new SlimefunItemStack("PICKAXE_OF_CONTAINMENT", Material.IRON_PICKAXE, "&c刷怪笼之镐", "", "&9可以获取刷怪笼"); - public static final SlimefunItemStack EXPLOSIVE_PICKAXE = new SlimefunItemStack("EXPLOSIVE_PICKAXE", Material.DIAMOND_PICKAXE, "&e爆炸镐", "", "&r允许你在一瞬间挖掘矿物", "", "&9在挖矿时有时运效果"); - public static final SlimefunItemStack EXPLOSIVE_SHOVEL = new SlimefunItemStack("EXPLOSIVE_SHOVEL", Material.DIAMOND_SHOVEL, "&e爆炸铲", "", "&r让你一下子就能挖掉很多方块"); - public static final SlimefunItemStack PICKAXE_OF_THE_SEEKER = new SlimefunItemStack("PICKAXE_OF_THE_SEEKER", Material.DIAMOND_PICKAXE, "&a寻矿镐", "&r使用时将会指出你附近的矿物", "&r但可能它会受到损伤", "", "&7&e右键&7 以寻找四周的矿物"); - public static final SlimefunItemStack COBALT_PICKAXE = new SlimefunItemStack("COBALT_PICKAXE", Material.IRON_PICKAXE, "&9钴镐"); - public static final SlimefunItemStack PICKAXE_OF_VEIN_MINING = new SlimefunItemStack("PICKAXE_OF_VEIN_MINING", Material.DIAMOND_PICKAXE, "&e矿脉镐", "", "&r这个镐子将会挖出", "&r整个矿脉的矿物..."); - public static final SlimefunItemStack CLIMBING_PICK = new SlimefunItemStack("CLIMBING_PICK", Material.IRON_PICKAXE, "&b攀岩镐", "", "&f让你能够在右键后", "&f攀爬到指定平面上.", "&f附魔效率之后攀爬速度将会提升"); + public static final SlimefunItemStack SMELTERS_PICKAXE = + new SlimefunItemStack("SMELTERS_PICKAXE", Material.DIAMOND_PICKAXE, "&6熔炉镐", "&c&l自动熔炼", "", "&9在挖矿时有时运效果"); + public static final SlimefunItemStack LUMBER_AXE = + new SlimefunItemStack("LUMBER_AXE", Material.DIAMOND_AXE, "&6伐木斧", "&a&o砍倒整棵树木..."); + public static final SlimefunItemStack PICKAXE_OF_CONTAINMENT = + new SlimefunItemStack("PICKAXE_OF_CONTAINMENT", Material.IRON_PICKAXE, "&c刷怪笼之镐", "", "&9可以获取刷怪笼"); + public static final SlimefunItemStack EXPLOSIVE_PICKAXE = new SlimefunItemStack( + "EXPLOSIVE_PICKAXE", Material.DIAMOND_PICKAXE, "&e爆炸镐", "", "&r允许你在一瞬间挖掘矿物", "", "&9在挖矿时有时运效果"); + public static final SlimefunItemStack EXPLOSIVE_SHOVEL = + new SlimefunItemStack("EXPLOSIVE_SHOVEL", Material.DIAMOND_SHOVEL, "&e爆炸铲", "", "&r让你一下子就能挖掉很多方块"); + public static final SlimefunItemStack PICKAXE_OF_THE_SEEKER = new SlimefunItemStack( + "PICKAXE_OF_THE_SEEKER", + Material.DIAMOND_PICKAXE, + "&a寻矿镐", + "&r使用时将会指出你附近的矿物", + "&r但可能它会受到损伤", + "", + "&7&e右键&7 以寻找四周的矿物"); + public static final SlimefunItemStack COBALT_PICKAXE = + new SlimefunItemStack("COBALT_PICKAXE", Material.IRON_PICKAXE, "&9钴镐"); + public static final SlimefunItemStack PICKAXE_OF_VEIN_MINING = new SlimefunItemStack( + "PICKAXE_OF_VEIN_MINING", Material.DIAMOND_PICKAXE, "&e矿脉镐", "", "&r这个镐子将会挖出", "&r整个矿脉的矿物..."); + public static final SlimefunItemStack CLIMBING_PICK = new SlimefunItemStack( + "CLIMBING_PICK", Material.IRON_PICKAXE, "&b攀岩镐", "", "&f让你能够在右键后", "&f攀爬到指定平面上.", "&f附魔效率之后攀爬速度将会提升"); static { COBALT_PICKAXE.addUnsafeEnchantment(Enchantment.DURABILITY, 10); @@ -214,39 +716,97 @@ private SlimefunItems() { } /* Armor */ - public static final SlimefunItemStack GLOWSTONE_HELMET = new SlimefunItemStack("GLOWSTONE_HELMET", Material.LEATHER_HELMET, Color.YELLOW, "&e&l萤石头盔", "", "&a&o像太阳一样闪耀!", "", "&9+ 夜视效果"); - public static final SlimefunItemStack GLOWSTONE_CHESTPLATE = new SlimefunItemStack("GLOWSTONE_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.YELLOW, "&e&l萤石胸甲", "", "&a&o像太阳一样闪耀!", "", "&9+ 夜视效果"); - public static final SlimefunItemStack GLOWSTONE_LEGGINGS = new SlimefunItemStack("GLOWSTONE_LEGGINGS", Material.LEATHER_LEGGINGS, Color.YELLOW, "&e&l萤石护腿", "", "&a&o像太阳一样闪耀!", "", "&9+ 夜视效果"); - public static final SlimefunItemStack GLOWSTONE_BOOTS = new SlimefunItemStack("GLOWSTONE_BOOTS", Material.LEATHER_BOOTS, Color.YELLOW, "&e&l萤石靴子", "", "&a&o像太阳一样闪耀!", "", "&9+ 夜视效果"); - public static final SlimefunItemStack RAINBOW_LEATHER = new SlimefunItemStack("RAINBOW_LEATHER", Material.RABBIT_HIDE, Color.FUCHSIA, "&d彩虹皮革", "", "&f用于合成彩虹装备"); - public static final SlimefunItemStack RAINBOW_HELMET = new SlimefunItemStack("RAINBOW_HELMET", Material.LEATHER_HELMET, Color.FUCHSIA, "&d&l彩虹头盔", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_CHESTPLATE = new SlimefunItemStack("RAINBOW_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.FUCHSIA, "&d&l彩虹胸甲", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_LEGGINGS = new SlimefunItemStack("RAINBOW_LEGGINGS", Material.LEATHER_LEGGINGS, Color.FUCHSIA, "&d&l彩虹护腿", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_BOOTS = new SlimefunItemStack("RAINBOW_BOOTS", Material.LEATHER_BOOTS, Color.FUCHSIA, "&d&l彩虹靴子", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack ENDER_HELMET = new SlimefunItemStack("ENDER_HELMET", Material.LEATHER_HELMET, Color.fromRGB(28, 25, 112), "&5&l末影头盔", "", "&a&o任意移动"); - public static final SlimefunItemStack ENDER_CHESTPLATE = new SlimefunItemStack("ENDER_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.fromRGB(28, 25, 112), "&5&l末影胸甲", "", "&a&o任意移动"); - public static final SlimefunItemStack ENDER_LEGGINGS = new SlimefunItemStack("ENDER_LEGGINGS", Material.LEATHER_LEGGINGS, Color.fromRGB(28, 25, 112), "&5&l末影护腿", "", "&a&o任意移动"); - public static final SlimefunItemStack ENDER_BOOTS = new SlimefunItemStack("ENDER_BOOTS", Material.LEATHER_BOOTS, Color.fromRGB(28, 25, 112), "&5&l末影靴子", "", "&a&o任意移动", "", "&9+ 使用末影珍珠时无伤害"); - - public static final SlimefunItemStack SLIME_HELMET = new SlimefunItemStack("SLIME_HELMET", Material.LEATHER_HELMET, Color.LIME, "&a&l史莱姆头盔", "", "&a&o有弹性的感觉"); - public static final SlimefunItemStack SLIME_CHESTPLATE = new SlimefunItemStack("SLIME_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.LIME, "&a&l史莱姆胸甲", "", "&a&o有弹性的感觉"); - public static final SlimefunItemStack SLIME_LEGGINGS = new SlimefunItemStack("SLIME_LEGGINGS", Material.LEATHER_LEGGINGS, Color.LIME, "&a&l史莱姆护腿", "", "&a&o有弹性的感觉", "", "&9+ 速度"); - public static final SlimefunItemStack SLIME_BOOTS = new SlimefunItemStack("SLIME_BOOTS", Material.LEATHER_BOOTS, Color.LIME, "&a&l史莱姆靴子", "", "&a&o有弹性的感觉", "", "&9+ 跳跃提升", "&9+ 减免摔落伤害"); - - public static final SlimefunItemStack CACTUS_HELMET = new SlimefunItemStack("CACTUS_HELMET", Material.LEATHER_HELMET, Color.GREEN, "&2仙人掌头盔"); - public static final SlimefunItemStack CACTUS_CHESTPLATE = new SlimefunItemStack("CACTUS_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.GREEN, "&2仙人掌胸甲"); - public static final SlimefunItemStack CACTUS_LEGGINGS = new SlimefunItemStack("CACTUS_LEGGINGS", Material.LEATHER_LEGGINGS, Color.GREEN, "&2仙人掌护腿"); - public static final SlimefunItemStack CACTUS_BOOTS = new SlimefunItemStack("CACTUS_BOOTS", Material.LEATHER_BOOTS, Color.GREEN, "&2仙人掌靴子"); - - public static final SlimefunItemStack DAMASCUS_STEEL_HELMET = new SlimefunItemStack("DAMASCUS_STEEL_HELMET", Material.IRON_HELMET, "&7大马士革钢头盔"); - public static final SlimefunItemStack DAMASCUS_STEEL_CHESTPLATE = new SlimefunItemStack("DAMASCUS_STEEL_CHESTPLATE", Material.IRON_CHESTPLATE, "&7大马士革钢胸甲"); - public static final SlimefunItemStack DAMASCUS_STEEL_LEGGINGS = new SlimefunItemStack("DAMASCUS_STEEL_LEGGINGS", Material.IRON_LEGGINGS, "&7大马士革钢护腿"); - public static final SlimefunItemStack DAMASCUS_STEEL_BOOTS = new SlimefunItemStack("DAMASCUS_STEEL_BOOTS", Material.IRON_BOOTS, "&7大马士革钢靴子"); - - public static final SlimefunItemStack REINFORCED_ALLOY_HELMET = new SlimefunItemStack("REINFORCED_ALLOY_HELMET", Material.IRON_HELMET, "&b强化合金头盔"); - public static final SlimefunItemStack REINFORCED_ALLOY_CHESTPLATE = new SlimefunItemStack("REINFORCED_ALLOY_CHESTPLATE", Material.IRON_CHESTPLATE, "&b强化合金胸甲"); - public static final SlimefunItemStack REINFORCED_ALLOY_LEGGINGS = new SlimefunItemStack("REINFORCED_ALLOY_LEGGINGS", Material.IRON_LEGGINGS, "&b强化合金护腿"); - public static final SlimefunItemStack REINFORCED_ALLOY_BOOTS = new SlimefunItemStack("REINFORCED_ALLOY_BOOTS", Material.IRON_BOOTS, "&b强化合金靴子"); + public static final SlimefunItemStack GLOWSTONE_HELMET = new SlimefunItemStack( + "GLOWSTONE_HELMET", Material.LEATHER_HELMET, Color.YELLOW, "&e&l萤石头盔", "", "&a&o像太阳一样闪耀!", "", "&9+ 夜视效果"); + public static final SlimefunItemStack GLOWSTONE_CHESTPLATE = new SlimefunItemStack( + "GLOWSTONE_CHESTPLATE", + Material.LEATHER_CHESTPLATE, + Color.YELLOW, + "&e&l萤石胸甲", + "", + "&a&o像太阳一样闪耀!", + "", + "&9+ 夜视效果"); + public static final SlimefunItemStack GLOWSTONE_LEGGINGS = new SlimefunItemStack( + "GLOWSTONE_LEGGINGS", + Material.LEATHER_LEGGINGS, + Color.YELLOW, + "&e&l萤石护腿", + "", + "&a&o像太阳一样闪耀!", + "", + "&9+ 夜视效果"); + public static final SlimefunItemStack GLOWSTONE_BOOTS = new SlimefunItemStack( + "GLOWSTONE_BOOTS", Material.LEATHER_BOOTS, Color.YELLOW, "&e&l萤石靴子", "", "&a&o像太阳一样闪耀!", "", "&9+ 夜视效果"); + public static final SlimefunItemStack RAINBOW_LEATHER = + new SlimefunItemStack("RAINBOW_LEATHER", Material.RABBIT_HIDE, Color.FUCHSIA, "&d彩虹皮革", "", "&f用于合成彩虹装备"); + public static final SlimefunItemStack RAINBOW_HELMET = new SlimefunItemStack( + "RAINBOW_HELMET", Material.LEATHER_HELMET, Color.FUCHSIA, "&d&l彩虹头盔", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_CHESTPLATE = new SlimefunItemStack( + "RAINBOW_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.FUCHSIA, "&d&l彩虹胸甲", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_LEGGINGS = new SlimefunItemStack( + "RAINBOW_LEGGINGS", Material.LEATHER_LEGGINGS, Color.FUCHSIA, "&d&l彩虹护腿", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_BOOTS = new SlimefunItemStack( + "RAINBOW_BOOTS", Material.LEATHER_BOOTS, Color.FUCHSIA, "&d&l彩虹靴子", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack ENDER_HELMET = new SlimefunItemStack( + "ENDER_HELMET", Material.LEATHER_HELMET, Color.fromRGB(28, 25, 112), "&5&l末影头盔", "", "&a&o任意移动"); + public static final SlimefunItemStack ENDER_CHESTPLATE = new SlimefunItemStack( + "ENDER_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.fromRGB(28, 25, 112), "&5&l末影胸甲", "", "&a&o任意移动"); + public static final SlimefunItemStack ENDER_LEGGINGS = new SlimefunItemStack( + "ENDER_LEGGINGS", Material.LEATHER_LEGGINGS, Color.fromRGB(28, 25, 112), "&5&l末影护腿", "", "&a&o任意移动"); + public static final SlimefunItemStack ENDER_BOOTS = new SlimefunItemStack( + "ENDER_BOOTS", + Material.LEATHER_BOOTS, + Color.fromRGB(28, 25, 112), + "&5&l末影靴子", + "", + "&a&o任意移动", + "", + "&9+ 使用末影珍珠时无伤害"); + + public static final SlimefunItemStack SLIME_HELMET = + new SlimefunItemStack("SLIME_HELMET", Material.LEATHER_HELMET, Color.LIME, "&a&l史莱姆头盔", "", "&a&o有弹性的感觉"); + public static final SlimefunItemStack SLIME_CHESTPLATE = new SlimefunItemStack( + "SLIME_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.LIME, "&a&l史莱姆胸甲", "", "&a&o有弹性的感觉"); + public static final SlimefunItemStack SLIME_LEGGINGS = new SlimefunItemStack( + "SLIME_LEGGINGS", Material.LEATHER_LEGGINGS, Color.LIME, "&a&l史莱姆护腿", "", "&a&o有弹性的感觉", "", "&9+ 速度"); + public static final SlimefunItemStack SLIME_BOOTS = new SlimefunItemStack( + "SLIME_BOOTS", + Material.LEATHER_BOOTS, + Color.LIME, + "&a&l史莱姆靴子", + "", + "&a&o有弹性的感觉", + "", + "&9+ 跳跃提升", + "&9+ 减免摔落伤害"); + + public static final SlimefunItemStack CACTUS_HELMET = + new SlimefunItemStack("CACTUS_HELMET", Material.LEATHER_HELMET, Color.GREEN, "&2仙人掌头盔"); + public static final SlimefunItemStack CACTUS_CHESTPLATE = + new SlimefunItemStack("CACTUS_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.GREEN, "&2仙人掌胸甲"); + public static final SlimefunItemStack CACTUS_LEGGINGS = + new SlimefunItemStack("CACTUS_LEGGINGS", Material.LEATHER_LEGGINGS, Color.GREEN, "&2仙人掌护腿"); + public static final SlimefunItemStack CACTUS_BOOTS = + new SlimefunItemStack("CACTUS_BOOTS", Material.LEATHER_BOOTS, Color.GREEN, "&2仙人掌靴子"); + + public static final SlimefunItemStack DAMASCUS_STEEL_HELMET = + new SlimefunItemStack("DAMASCUS_STEEL_HELMET", Material.IRON_HELMET, "&7大马士革钢头盔"); + public static final SlimefunItemStack DAMASCUS_STEEL_CHESTPLATE = + new SlimefunItemStack("DAMASCUS_STEEL_CHESTPLATE", Material.IRON_CHESTPLATE, "&7大马士革钢胸甲"); + public static final SlimefunItemStack DAMASCUS_STEEL_LEGGINGS = + new SlimefunItemStack("DAMASCUS_STEEL_LEGGINGS", Material.IRON_LEGGINGS, "&7大马士革钢护腿"); + public static final SlimefunItemStack DAMASCUS_STEEL_BOOTS = + new SlimefunItemStack("DAMASCUS_STEEL_BOOTS", Material.IRON_BOOTS, "&7大马士革钢靴子"); + + public static final SlimefunItemStack REINFORCED_ALLOY_HELMET = + new SlimefunItemStack("REINFORCED_ALLOY_HELMET", Material.IRON_HELMET, "&b强化合金头盔"); + public static final SlimefunItemStack REINFORCED_ALLOY_CHESTPLATE = + new SlimefunItemStack("REINFORCED_ALLOY_CHESTPLATE", Material.IRON_CHESTPLATE, "&b强化合金胸甲"); + public static final SlimefunItemStack REINFORCED_ALLOY_LEGGINGS = + new SlimefunItemStack("REINFORCED_ALLOY_LEGGINGS", Material.IRON_LEGGINGS, "&b强化合金护腿"); + public static final SlimefunItemStack REINFORCED_ALLOY_BOOTS = + new SlimefunItemStack("REINFORCED_ALLOY_BOOTS", Material.IRON_BOOTS, "&b强化合金靴子"); private static final List hazmatLore = new ArrayList<>(); @@ -257,10 +817,14 @@ private SlimefunItems() { hazmatLore.add(ChatColor.YELLOW + "- 免疫蜜蜂蛰咬伤害"); } - public static final SlimefunItemStack SCUBA_HELMET = new SlimefunItemStack("SCUBA_HELMET", Material.LEATHER_HELMET, Color.ORANGE, "&c潜水头盔", "", "&7让你能够在水下呼吸"); - public static final SlimefunItemStack HAZMAT_CHESTPLATE = new SlimefunItemStack("HAZMAT_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.ORANGE, "&c防化服", "", "&7让你能在火焰和岩浆里行走"); - public static final SlimefunItemStack HAZMAT_LEGGINGS = new SlimefunItemStack("HAZMAT_LEGGINGS", Material.LEATHER_LEGGINGS, Color.ORANGE, "&c防化护腿", hazmatLore.toArray(new String[0])); - public static final SlimefunItemStack HAZMAT_BOOTS = new SlimefunItemStack("RUBBER_BOOTS", Material.LEATHER_BOOTS, Color.BLACK, "&c防化靴", hazmatLore.toArray(new String[0])); + public static final SlimefunItemStack SCUBA_HELMET = + new SlimefunItemStack("SCUBA_HELMET", Material.LEATHER_HELMET, Color.ORANGE, "&c潜水头盔", "", "&7让你能够在水下呼吸"); + public static final SlimefunItemStack HAZMAT_CHESTPLATE = new SlimefunItemStack( + "HAZMAT_CHESTPLATE", Material.LEATHER_CHESTPLATE, Color.ORANGE, "&c防化服", "", "&7让你能在火焰和岩浆里行走"); + public static final SlimefunItemStack HAZMAT_LEGGINGS = new SlimefunItemStack( + "HAZMAT_LEGGINGS", Material.LEATHER_LEGGINGS, Color.ORANGE, "&c防化护腿", hazmatLore.toArray(new String[0])); + public static final SlimefunItemStack HAZMAT_BOOTS = new SlimefunItemStack( + "RUBBER_BOOTS", Material.LEATHER_BOOTS, Color.BLACK, "&c防化靴", hazmatLore.toArray(new String[0])); static { ItemMeta helmetMeta = SCUBA_HELMET.getItemMeta(); @@ -276,27 +840,68 @@ private SlimefunItems() { HAZMAT_CHESTPLATE.setItemMeta(chestplateMeta); } - public static final SlimefunItemStack GILDED_IRON_HELMET = new SlimefunItemStack("GILDED_IRON_HELMET", Material.GOLDEN_HELMET, "&6镀金铁头盔"); - public static final SlimefunItemStack GILDED_IRON_CHESTPLATE = new SlimefunItemStack("GILDED_IRON_CHESTPLATE", Material.GOLDEN_CHESTPLATE, "&6镀金铁胸甲"); - public static final SlimefunItemStack GILDED_IRON_LEGGINGS = new SlimefunItemStack("GILDED_IRON_LEGGINGS", Material.GOLDEN_LEGGINGS, "&6镀金铁护腿"); - public static final SlimefunItemStack GILDED_IRON_BOOTS = new SlimefunItemStack("GILDED_IRON_BOOTS", Material.GOLDEN_BOOTS, "&6镀金铁靴子"); - - public static final SlimefunItemStack GOLDEN_HELMET_12K = new SlimefunItemStack("GOLD_12K_HELMET", Material.GOLDEN_HELMET, "&6金头盔", "&912克拉"); - public static final SlimefunItemStack GOLDEN_CHESTPLATE_12K = new SlimefunItemStack("GOLD_12K_CHESTPLATE", Material.GOLDEN_CHESTPLATE, "&6金胸甲", "&912克拉"); - public static final SlimefunItemStack GOLDEN_LEGGINGS_12K = new SlimefunItemStack("GOLD_12K_LEGGINGS", Material.GOLDEN_LEGGINGS, "&6金护腿", "&912克拉"); - public static final SlimefunItemStack GOLDEN_BOOTS_12K = new SlimefunItemStack("GOLD_12K_BOOTS", Material.GOLDEN_BOOTS, "&6金靴子", "&912克拉"); - - public static final SlimefunItemStack SLIME_HELMET_STEEL = new SlimefunItemStack("SLIME_STEEL_HELMET", Material.IRON_HELMET, "&a&l史莱姆头盔", "&7&o已强化", "", "&a&o有弹性的感觉"); - public static final SlimefunItemStack SLIME_CHESTPLATE_STEEL = new SlimefunItemStack("SLIME_STEEL_CHESTPLATE", Material.IRON_CHESTPLATE, "&a&l史莱姆胸甲", "&7&o已强化", "", "&a&o有弹性的感觉"); - public static final SlimefunItemStack SLIME_LEGGINGS_STEEL = new SlimefunItemStack("SLIME_STEEL_LEGGINGS", Material.IRON_LEGGINGS, "&a&l史莱姆护腿", "&7&o已强化", "", "&a&o有弹性的感觉", "", "&9+ 速度"); - public static final SlimefunItemStack SLIME_BOOTS_STEEL = new SlimefunItemStack("SLIME_STEEL_BOOTS", Material.IRON_BOOTS, "&a&l史莱姆靴子", "&7&o已强化", "", "&a&o有弹性的感觉", "", "&9+ 跳跃提升", "&9+ 减免摔落伤害"); - - public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack("BOOTS_OF_THE_STOMPER", Material.LEATHER_BOOTS, Color.AQUA, "&b践踏者之靴", "", "&9你受到的所有摔落伤害", "&9将转给附近的生物/玩家", "", "&9+ 减免摔落伤害"); - - public static final SlimefunItemStack BEE_HELMET = new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&l蜜蜂头盔", " ", "&f嗡嗡嗡"); - public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack("BEE_WINGS", Material.ELYTRA, "&e&l蜂翅", " ", "&f嗡嗡嗡", " ", "&9在接近地面时", "&9会启用缓降模式", " "); - public static final SlimefunItemStack BEE_LEGGINGS = new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&l蜜蜂护腿", " ", "&f嗡嗡嗡"); - public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack("BEE_BOOTS", Material.GOLDEN_BOOTS, "&e&l蜜蜂护靴", "&f嗡嗡嗡", "", "&e&o再次起飞时绝对没问题", "", "&9+ 跳跃提升", "&9+ 减免摔落伤害"); + public static final SlimefunItemStack GILDED_IRON_HELMET = + new SlimefunItemStack("GILDED_IRON_HELMET", Material.GOLDEN_HELMET, "&6镀金铁头盔"); + public static final SlimefunItemStack GILDED_IRON_CHESTPLATE = + new SlimefunItemStack("GILDED_IRON_CHESTPLATE", Material.GOLDEN_CHESTPLATE, "&6镀金铁胸甲"); + public static final SlimefunItemStack GILDED_IRON_LEGGINGS = + new SlimefunItemStack("GILDED_IRON_LEGGINGS", Material.GOLDEN_LEGGINGS, "&6镀金铁护腿"); + public static final SlimefunItemStack GILDED_IRON_BOOTS = + new SlimefunItemStack("GILDED_IRON_BOOTS", Material.GOLDEN_BOOTS, "&6镀金铁靴子"); + + public static final SlimefunItemStack GOLDEN_HELMET_12K = + new SlimefunItemStack("GOLD_12K_HELMET", Material.GOLDEN_HELMET, "&6金头盔", "&912克拉"); + public static final SlimefunItemStack GOLDEN_CHESTPLATE_12K = + new SlimefunItemStack("GOLD_12K_CHESTPLATE", Material.GOLDEN_CHESTPLATE, "&6金胸甲", "&912克拉"); + public static final SlimefunItemStack GOLDEN_LEGGINGS_12K = + new SlimefunItemStack("GOLD_12K_LEGGINGS", Material.GOLDEN_LEGGINGS, "&6金护腿", "&912克拉"); + public static final SlimefunItemStack GOLDEN_BOOTS_12K = + new SlimefunItemStack("GOLD_12K_BOOTS", Material.GOLDEN_BOOTS, "&6金靴子", "&912克拉"); + + public static final SlimefunItemStack SLIME_HELMET_STEEL = + new SlimefunItemStack("SLIME_STEEL_HELMET", Material.IRON_HELMET, "&a&l史莱姆头盔", "&7&o已强化", "", "&a&o有弹性的感觉"); + public static final SlimefunItemStack SLIME_CHESTPLATE_STEEL = new SlimefunItemStack( + "SLIME_STEEL_CHESTPLATE", Material.IRON_CHESTPLATE, "&a&l史莱姆胸甲", "&7&o已强化", "", "&a&o有弹性的感觉"); + public static final SlimefunItemStack SLIME_LEGGINGS_STEEL = new SlimefunItemStack( + "SLIME_STEEL_LEGGINGS", Material.IRON_LEGGINGS, "&a&l史莱姆护腿", "&7&o已强化", "", "&a&o有弹性的感觉", "", "&9+ 速度"); + public static final SlimefunItemStack SLIME_BOOTS_STEEL = new SlimefunItemStack( + "SLIME_STEEL_BOOTS", + Material.IRON_BOOTS, + "&a&l史莱姆靴子", + "&7&o已强化", + "", + "&a&o有弹性的感觉", + "", + "&9+ 跳跃提升", + "&9+ 减免摔落伤害"); + + public static final SlimefunItemStack BOOTS_OF_THE_STOMPER = new SlimefunItemStack( + "BOOTS_OF_THE_STOMPER", + Material.LEATHER_BOOTS, + Color.AQUA, + "&b践踏者之靴", + "", + "&9你受到的所有摔落伤害", + "&9将转给附近的生物/玩家", + "", + "&9+ 减免摔落伤害"); + + public static final SlimefunItemStack BEE_HELMET = + new SlimefunItemStack("BEE_HELMET", Material.GOLDEN_HELMET, "&e&l蜜蜂头盔", " ", "&f嗡嗡嗡"); + public static final SlimefunItemStack BEE_WINGS = new SlimefunItemStack( + "BEE_WINGS", Material.ELYTRA, "&e&l蜂翅", " ", "&f嗡嗡嗡", " ", "&9在接近地面时", "&9会启用缓降模式", " "); + public static final SlimefunItemStack BEE_LEGGINGS = + new SlimefunItemStack("BEE_LEGGINGS", Material.GOLDEN_LEGGINGS, "&e&l蜜蜂护腿", " ", "&f嗡嗡嗡"); + public static final SlimefunItemStack BEE_BOOTS = new SlimefunItemStack( + "BEE_BOOTS", + Material.GOLDEN_BOOTS, + "&e&l蜜蜂护靴", + "&f嗡嗡嗡", + "", + "&e&o再次起飞时绝对没问题", + "", + "&9+ 跳跃提升", + "&9+ 减免摔落伤害"); static { Map cactusEnchs = new HashMap<>(); @@ -360,205 +965,440 @@ private SlimefunItems() { } /* Misc */ - public static final SlimefunItemStack MAGIC_LUMP_1 = new SlimefunItemStack("MAGIC_LUMP_1", Material.GOLD_NUGGET, "&6魔法结晶 &7- &eI", "", "&c&o等级: I"); - public static final SlimefunItemStack MAGIC_LUMP_2 = new SlimefunItemStack("MAGIC_LUMP_2", Material.GOLD_NUGGET, "&6魔法结晶 &7- &eII", "", "&c&o等级: II"); - public static final SlimefunItemStack MAGIC_LUMP_3 = new SlimefunItemStack("MAGIC_LUMP_3", Material.GOLD_NUGGET, "&6魔法结晶 &7- &eIII", "", "&c&o等级: III"); - public static final SlimefunItemStack ENDER_LUMP_1 = new SlimefunItemStack("ENDER_LUMP_1", Material.GOLD_NUGGET, "&5末影结晶 &7- &eI", "", "&c&o等级: I"); - public static final SlimefunItemStack ENDER_LUMP_2 = new SlimefunItemStack("ENDER_LUMP_2", Material.GOLD_NUGGET, "&5末影结晶 &7- &eII", "", "&c&o等级: II"); - public static final SlimefunItemStack ENDER_LUMP_3 = new SlimefunItemStack("ENDER_LUMP_3", Material.GOLD_NUGGET, "&5末影结晶 &7- &eIII", "", "&c&o等级: III"); - public static final SlimefunItemStack MAGICAL_BOOK_COVER = new SlimefunItemStack("MAGICAL_BOOK_COVER", Material.PAPER, "&6魔法书皮", "", "&a&o用于各种魔法书"); - public static final SlimefunItemStack MAGICAL_GLASS = new SlimefunItemStack("MAGICAL_GLASS", Material.GLASS_PANE, "&6魔法玻璃", "", "&a&o被多种魔法道具使用"); - public static final SlimefunItemStack SYNTHETIC_SHULKER_SHELL = new SlimefunItemStack("SYNTHETIC_SHULKER_SHELL", Material.SHULKER_SHELL, "&d人造潜影壳", "", "&f可以用于工作台合成", "&f就像普通的潜影壳一样"); - public static final SlimefunItemStack BASIC_CIRCUIT_BOARD = new SlimefunItemStack("BASIC_CIRCUIT_BOARD", Material.ACTIVATOR_RAIL, "&b基础电路板"); - public static final SlimefunItemStack ADVANCED_CIRCUIT_BOARD = new SlimefunItemStack("ADVANCED_CIRCUIT_BOARD", Material.POWERED_RAIL, "&b高级电路板"); + public static final SlimefunItemStack MAGIC_LUMP_1 = + new SlimefunItemStack("MAGIC_LUMP_1", Material.GOLD_NUGGET, "&6魔法结晶 &7- &eI", "", "&c&o等级: I"); + public static final SlimefunItemStack MAGIC_LUMP_2 = + new SlimefunItemStack("MAGIC_LUMP_2", Material.GOLD_NUGGET, "&6魔法结晶 &7- &eII", "", "&c&o等级: II"); + public static final SlimefunItemStack MAGIC_LUMP_3 = + new SlimefunItemStack("MAGIC_LUMP_3", Material.GOLD_NUGGET, "&6魔法结晶 &7- &eIII", "", "&c&o等级: III"); + public static final SlimefunItemStack ENDER_LUMP_1 = + new SlimefunItemStack("ENDER_LUMP_1", Material.GOLD_NUGGET, "&5末影结晶 &7- &eI", "", "&c&o等级: I"); + public static final SlimefunItemStack ENDER_LUMP_2 = + new SlimefunItemStack("ENDER_LUMP_2", Material.GOLD_NUGGET, "&5末影结晶 &7- &eII", "", "&c&o等级: II"); + public static final SlimefunItemStack ENDER_LUMP_3 = + new SlimefunItemStack("ENDER_LUMP_3", Material.GOLD_NUGGET, "&5末影结晶 &7- &eIII", "", "&c&o等级: III"); + public static final SlimefunItemStack MAGICAL_BOOK_COVER = + new SlimefunItemStack("MAGICAL_BOOK_COVER", Material.PAPER, "&6魔法书皮", "", "&a&o用于各种魔法书"); + public static final SlimefunItemStack MAGICAL_GLASS = + new SlimefunItemStack("MAGICAL_GLASS", Material.GLASS_PANE, "&6魔法玻璃", "", "&a&o被多种魔法道具使用"); + public static final SlimefunItemStack SYNTHETIC_SHULKER_SHELL = new SlimefunItemStack( + "SYNTHETIC_SHULKER_SHELL", Material.SHULKER_SHELL, "&d人造潜影壳", "", "&f可以用于工作台合成", "&f就像普通的潜影壳一样"); + public static final SlimefunItemStack BASIC_CIRCUIT_BOARD = + new SlimefunItemStack("BASIC_CIRCUIT_BOARD", Material.ACTIVATOR_RAIL, "&b基础电路板"); + public static final SlimefunItemStack ADVANCED_CIRCUIT_BOARD = + new SlimefunItemStack("ADVANCED_CIRCUIT_BOARD", Material.POWERED_RAIL, "&b高级电路板"); public static final SlimefunItemStack WHEAT_FLOUR = new SlimefunItemStack("WHEAT_FLOUR", Material.SUGAR, "&r小麦粉"); public static final SlimefunItemStack STEEL_PLATE = new SlimefunItemStack("STEEL_PLATE", Material.PAPER, "&7&l钢板"); public static final SlimefunItemStack BATTERY = new SlimefunItemStack("BATTERY", HeadTexture.BATTERY, "&6电池"); public static final SlimefunItemStack CARBON = new SlimefunItemStack("CARBON", HeadTexture.CARBON, "&e碳"); - public static final SlimefunItemStack COMPRESSED_CARBON = new SlimefunItemStack("COMPRESSED_CARBON", HeadTexture.COMPRESSED_CARBON, "&c压缩碳"); - public static final SlimefunItemStack CARBON_CHUNK = new SlimefunItemStack("CARBON_CHUNK", HeadTexture.CARBON, "&4碳块"); - public static final SlimefunItemStack STEEL_THRUSTER = new SlimefunItemStack("STEEL_THRUSTER", Material.BUCKET, "&7&l钢推进器"); - public static final SlimefunItemStack POWER_CRYSTAL = new SlimefunItemStack("POWER_CRYSTAL", HeadTexture.POWER_CRYSTAL, "&c&l能量水晶"); + public static final SlimefunItemStack COMPRESSED_CARBON = + new SlimefunItemStack("COMPRESSED_CARBON", HeadTexture.COMPRESSED_CARBON, "&c压缩碳"); + public static final SlimefunItemStack CARBON_CHUNK = + new SlimefunItemStack("CARBON_CHUNK", HeadTexture.CARBON, "&4碳块"); + public static final SlimefunItemStack STEEL_THRUSTER = + new SlimefunItemStack("STEEL_THRUSTER", Material.BUCKET, "&7&l钢推进器"); + public static final SlimefunItemStack POWER_CRYSTAL = + new SlimefunItemStack("POWER_CRYSTAL", HeadTexture.POWER_CRYSTAL, "&c&l能量水晶"); public static final SlimefunItemStack CHAIN = new SlimefunItemStack("CHAIN", Material.STRING, "&b锁链"); public static final SlimefunItemStack HOOK = new SlimefunItemStack("HOOK", Material.FLINT, "&b钩子"); public static final SlimefunItemStack SIFTED_ORE = new SlimefunItemStack("SIFTED_ORE", Material.GUNPOWDER, "&6筛矿"); - public static final SlimefunItemStack STONE_CHUNK = new SlimefunItemStack("STONE_CHUNK", HeadTexture.STONE_CHUNK, "&6石块"); - public static final SlimefunItemStack LAVA_CRYSTAL = new SlimefunItemStack("LAVA_CRYSTAL", HeadTexture.LAVA_CRYSTAL, "&4岩浆水晶"); + public static final SlimefunItemStack STONE_CHUNK = + new SlimefunItemStack("STONE_CHUNK", HeadTexture.STONE_CHUNK, "&6石块"); + public static final SlimefunItemStack LAVA_CRYSTAL = + new SlimefunItemStack("LAVA_CRYSTAL", HeadTexture.LAVA_CRYSTAL, "&4岩浆水晶"); public static final SlimefunItemStack SALT = new SlimefunItemStack("SALT", Material.SUGAR, "&r盐"); public static final SlimefunItemStack CHEESE = new SlimefunItemStack("CHEESE", HeadTexture.CHEESE, "&r黄油"); public static final SlimefunItemStack BUTTER = new SlimefunItemStack("BUTTER", HeadTexture.BUTTER, "&r奶酪"); - public static final SlimefunItemStack DUCT_TAPE = new SlimefunItemStack("DUCT_TAPE", HeadTexture.DUCT_TAPE, "&8强力胶布", "", "&r可以用这个在自动铁砧里", "&r修复物品"); - public static final SlimefunItemStack HEAVY_CREAM = new SlimefunItemStack("HEAVY_CREAM", Material.SNOWBALL, "&r浓奶油"); - public static final SlimefunItemStack CRUSHED_ORE = new SlimefunItemStack("CRUSHED_ORE", Material.GUNPOWDER, "&6已粉碎的矿石"); - public static final SlimefunItemStack PULVERIZED_ORE = new SlimefunItemStack("PULVERIZED_ORE", Material.GUNPOWDER, "&6粉末状的矿石"); - public static final SlimefunItemStack PURE_ORE_CLUSTER = new SlimefunItemStack("PURE_ORE_CLUSTER", Material.GUNPOWDER, "&6纯矿簇"); - public static final SlimefunItemStack SMALL_URANIUM = new SlimefunItemStack("SMALL_URANIUM", HeadTexture.URANIUM, "&c一小块铀", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack TINY_URANIUM = new SlimefunItemStack("TINY_URANIUM", HeadTexture.URANIUM, "&c一小撮铀", "", LoreBuilder.radioactive(Radioactivity.LOW)); + public static final SlimefunItemStack DUCT_TAPE = + new SlimefunItemStack("DUCT_TAPE", HeadTexture.DUCT_TAPE, "&8强力胶布", "", "&r可以用这个在自动铁砧里", "&r修复物品"); + public static final SlimefunItemStack HEAVY_CREAM = + new SlimefunItemStack("HEAVY_CREAM", Material.SNOWBALL, "&r浓奶油"); + public static final SlimefunItemStack CRUSHED_ORE = + new SlimefunItemStack("CRUSHED_ORE", Material.GUNPOWDER, "&6已粉碎的矿石"); + public static final SlimefunItemStack PULVERIZED_ORE = + new SlimefunItemStack("PULVERIZED_ORE", Material.GUNPOWDER, "&6粉末状的矿石"); + public static final SlimefunItemStack PURE_ORE_CLUSTER = + new SlimefunItemStack("PURE_ORE_CLUSTER", Material.GUNPOWDER, "&6纯矿簇"); + public static final SlimefunItemStack SMALL_URANIUM = new SlimefunItemStack( + "SMALL_URANIUM", + HeadTexture.URANIUM, + "&c一小块铀", + "", + LoreBuilder.radioactive(Radioactivity.MODERATE), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack TINY_URANIUM = new SlimefunItemStack( + "TINY_URANIUM", HeadTexture.URANIUM, "&c一小撮铀", "", LoreBuilder.radioactive(Radioactivity.LOW)); public static final SlimefunItemStack MAGNET = new SlimefunItemStack("MAGNET", HeadTexture.MAGNET, "&c磁铁"); - public static final SlimefunItemStack NECROTIC_SKULL = new SlimefunItemStack("NECROTIC_SKULL", HeadTexture.NECROTIC_SKULL, "&c坏死颅骨"); - public static final SlimefunItemStack ESSENCE_OF_AFTERLIFE = new SlimefunItemStack("ESSENCE_OF_AFTERLIFE", Material.GUNPOWDER, "&4来世精华"); - public static final SlimefunItemStack STRANGE_NETHER_GOO = new SlimefunItemStack("STRANGE_NETHER_GOO", Material.PURPLE_DYE, "&5奇怪的下界粘液", "", "&f一种奇怪的物质", "&f可以和猪灵以物换物获得"); - public static final SlimefunItemStack ELECTRO_MAGNET = new SlimefunItemStack("ELECTRO_MAGNET", HeadTexture.MAGNET, "&c电磁铁"); - public static final SlimefunItemStack HEATING_COIL = new SlimefunItemStack("HEATING_COIL", HeadTexture.HEATING_COIL, "&c加热线圈"); - public static final SlimefunItemStack COOLING_UNIT = new SlimefunItemStack("COOLING_UNIT", HeadTexture.COOLING_UNIT, "&b冷却装置"); - public static final SlimefunItemStack ELECTRIC_MOTOR = new SlimefunItemStack("ELECTRIC_MOTOR", HeadTexture.MOTOR, "&c电动马达"); - public static final SlimefunItemStack CARGO_MOTOR = new SlimefunItemStack("CARGO_MOTOR", HeadTexture.CARGO_MOTOR, "&3货运马达", "", "&7货运网络相关机器重要的零件"); - public static final SlimefunItemStack SCROLL_OF_DIMENSIONAL_TELEPOSITION = new SlimefunItemStack("SCROLL_OF_DIMENSIONAL_TELEPOSITION", Material.PAPER, "&6维度传送卷轴", "", "&c这个卷轴可以便携地创建", "&c一个临时的黑洞", "&c将附近的实体都传送至", "&c另一个维度上", "&c所有东西都反转了", "", "&r就是说: 让实体转180°"); - public static final SlimefunItemStack TOME_OF_KNOWLEDGE_SHARING = new SlimefunItemStack("TOME_OF_KNOWLEDGE_SHARING", Material.ENCHANTED_BOOK, "&6学识巨著", "&7主人: &bNone", "", "&e右键&7 以绑定你的所有研究", "", "", "&e右键&7 以获得前任主人的所有研究"); - public static final SlimefunItemStack HARDENED_GLASS = new SlimefunItemStack("HARDENED_GLASS", Material.LIGHT_GRAY_STAINED_GLASS, "&7钢化玻璃", "", "&r可以抵抗爆炸"); - public static final SlimefunItemStack WITHER_PROOF_OBSIDIAN = new SlimefunItemStack("WITHER_PROOF_OBSIDIAN", Material.OBSIDIAN, "&5防凋灵黑曜石", "", "&r可以抵抗爆炸和", "&r凋灵的攻击"); - public static final SlimefunItemStack WITHER_PROOF_GLASS = new SlimefunItemStack("WITHER_PROOF_GLASS", Material.PURPLE_STAINED_GLASS, "&5防凋灵玻璃", "", "&r可以抵抗爆炸和", "&r凋灵的攻击"); - public static final SlimefunItemStack REINFORCED_PLATE = new SlimefunItemStack("REINFORCED_PLATE", Material.PAPER, "&7钢筋板"); - public static final SlimefunItemStack ANCIENT_PEDESTAL = new SlimefunItemStack("ANCIENT_PEDESTAL", Material.DISPENSER, "&d古代基座", "", "&5古代祭坛的一部分"); - public static final SlimefunItemStack ANCIENT_ALTAR = new SlimefunItemStack("ANCIENT_ALTAR", Material.ENCHANTING_TABLE, "&d古代祭坛", "", "&5在世界里建造祭坛", "&5并用古老的仪式合成物品"); - public static final SlimefunItemStack COPPER_WIRE = new SlimefunItemStack("COPPER_WIRE", Material.STRING, "&6铜线", "", "&6电子配件中的重要组成部分"); - public static final SlimefunItemStack CRAFTING_MOTOR = new SlimefunItemStack("CRAFTING_MOTOR", HeadTexture.CRAFTING_MOTOR, "&6合成机马达", "", "&7自动合成机重要的零件"); - - public static final SlimefunItemStack RAINBOW_WOOL = new SlimefunItemStack("RAINBOW_WOOL", Material.WHITE_WOOL, "&5彩虹羊毛", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_GLASS = new SlimefunItemStack("RAINBOW_GLASS", Material.WHITE_STAINED_GLASS, "&5彩虹玻璃", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_CLAY = new SlimefunItemStack("RAINBOW_CLAY", Material.WHITE_TERRACOTTA, "&5彩虹粘土块", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_GLASS_PANE = new SlimefunItemStack("RAINBOW_GLASS_PANE", Material.WHITE_STAINED_GLASS_PANE, "&5彩虹玻璃板", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_CONCRETE = new SlimefunItemStack("RAINBOW_CONCRETE", Material.WHITE_CONCRETE, "&5彩虹混凝土", "", LoreBuilder.RAINBOW); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA", Material.WHITE_GLAZED_TERRACOTTA, "&5彩虹带釉陶瓦", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack NECROTIC_SKULL = + new SlimefunItemStack("NECROTIC_SKULL", HeadTexture.NECROTIC_SKULL, "&c坏死颅骨"); + public static final SlimefunItemStack ESSENCE_OF_AFTERLIFE = + new SlimefunItemStack("ESSENCE_OF_AFTERLIFE", Material.GUNPOWDER, "&4来世精华"); + public static final SlimefunItemStack STRANGE_NETHER_GOO = new SlimefunItemStack( + "STRANGE_NETHER_GOO", Material.PURPLE_DYE, "&5奇怪的下界粘液", "", "&f一种奇怪的物质", "&f可以和猪灵以物换物获得"); + public static final SlimefunItemStack ELECTRO_MAGNET = + new SlimefunItemStack("ELECTRO_MAGNET", HeadTexture.MAGNET, "&c电磁铁"); + public static final SlimefunItemStack HEATING_COIL = + new SlimefunItemStack("HEATING_COIL", HeadTexture.HEATING_COIL, "&c加热线圈"); + public static final SlimefunItemStack COOLING_UNIT = + new SlimefunItemStack("COOLING_UNIT", HeadTexture.COOLING_UNIT, "&b冷却装置"); + public static final SlimefunItemStack ELECTRIC_MOTOR = + new SlimefunItemStack("ELECTRIC_MOTOR", HeadTexture.MOTOR, "&c电动马达"); + public static final SlimefunItemStack CARGO_MOTOR = + new SlimefunItemStack("CARGO_MOTOR", HeadTexture.CARGO_MOTOR, "&3货运马达", "", "&7货运网络相关机器重要的零件"); + public static final SlimefunItemStack SCROLL_OF_DIMENSIONAL_TELEPOSITION = new SlimefunItemStack( + "SCROLL_OF_DIMENSIONAL_TELEPOSITION", + Material.PAPER, + "&6维度传送卷轴", + "", + "&c这个卷轴可以便携地创建", + "&c一个临时的黑洞", + "&c将附近的实体都传送至", + "&c另一个维度上", + "&c所有东西都反转了", + "", + "&r就是说: 让实体转180°"); + public static final SlimefunItemStack TOME_OF_KNOWLEDGE_SHARING = new SlimefunItemStack( + "TOME_OF_KNOWLEDGE_SHARING", + Material.ENCHANTED_BOOK, + "&6学识巨著", + "&7主人: &bNone", + "", + "&e右键&7 以绑定你的所有研究", + "", + "", + "&e右键&7 以获得前任主人的所有研究"); + public static final SlimefunItemStack HARDENED_GLASS = + new SlimefunItemStack("HARDENED_GLASS", Material.LIGHT_GRAY_STAINED_GLASS, "&7钢化玻璃", "", "&r可以抵抗爆炸"); + public static final SlimefunItemStack WITHER_PROOF_OBSIDIAN = + new SlimefunItemStack("WITHER_PROOF_OBSIDIAN", Material.OBSIDIAN, "&5防凋灵黑曜石", "", "&r可以抵抗爆炸和", "&r凋灵的攻击"); + public static final SlimefunItemStack WITHER_PROOF_GLASS = new SlimefunItemStack( + "WITHER_PROOF_GLASS", Material.PURPLE_STAINED_GLASS, "&5防凋灵玻璃", "", "&r可以抵抗爆炸和", "&r凋灵的攻击"); + public static final SlimefunItemStack REINFORCED_PLATE = + new SlimefunItemStack("REINFORCED_PLATE", Material.PAPER, "&7钢筋板"); + public static final SlimefunItemStack ANCIENT_PEDESTAL = + new SlimefunItemStack("ANCIENT_PEDESTAL", Material.DISPENSER, "&d古代基座", "", "&5古代祭坛的一部分"); + public static final SlimefunItemStack ANCIENT_ALTAR = new SlimefunItemStack( + "ANCIENT_ALTAR", Material.ENCHANTING_TABLE, "&d古代祭坛", "", "&5在世界里建造祭坛", "&5并用古老的仪式合成物品"); + public static final SlimefunItemStack COPPER_WIRE = + new SlimefunItemStack("COPPER_WIRE", Material.STRING, "&6铜线", "", "&6电子配件中的重要组成部分"); + public static final SlimefunItemStack CRAFTING_MOTOR = + new SlimefunItemStack("CRAFTING_MOTOR", HeadTexture.CRAFTING_MOTOR, "&6合成机马达", "", "&7自动合成机重要的零件"); + + public static final SlimefunItemStack RAINBOW_WOOL = + new SlimefunItemStack("RAINBOW_WOOL", Material.WHITE_WOOL, "&5彩虹羊毛", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_GLASS = + new SlimefunItemStack("RAINBOW_GLASS", Material.WHITE_STAINED_GLASS, "&5彩虹玻璃", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_CLAY = + new SlimefunItemStack("RAINBOW_CLAY", Material.WHITE_TERRACOTTA, "&5彩虹粘土块", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_GLASS_PANE = new SlimefunItemStack( + "RAINBOW_GLASS_PANE", Material.WHITE_STAINED_GLASS_PANE, "&5彩虹玻璃板", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_CONCRETE = + new SlimefunItemStack("RAINBOW_CONCRETE", Material.WHITE_CONCRETE, "&5彩虹混凝土", "", LoreBuilder.RAINBOW); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA = new SlimefunItemStack( + "RAINBOW_GLAZED_TERRACOTTA", Material.WHITE_GLAZED_TERRACOTTA, "&5彩虹带釉陶瓦", "", LoreBuilder.RAINBOW); private static final String CHRISTMAS = ChatUtils.christmas("< 圣诞节版 >"); - public static final SlimefunItemStack RAINBOW_WOOL_XMAS = new SlimefunItemStack("RAINBOW_WOOL_XMAS", Material.WHITE_WOOL, "&5彩虹羊毛 &7(圣诞节版)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_GLASS_XMAS = new SlimefunItemStack("RAINBOW_GLASS_XMAS", Material.WHITE_STAINED_GLASS, "&5彩虹玻璃 &7(圣诞节版)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_CLAY_XMAS = new SlimefunItemStack("RAINBOW_CLAY_XMAS", Material.WHITE_TERRACOTTA, "&5彩虹粘土块 &7(圣诞节版)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_GLASS_PANE_XMAS = new SlimefunItemStack("RAINBOW_GLASS_PANE_XMAS", Material.WHITE_STAINED_GLASS_PANE, "&5彩虹玻璃板 &7(圣诞节版)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_CONCRETE_XMAS = new SlimefunItemStack("RAINBOW_CONCRETE_XMAS", Material.WHITE_CONCRETE, "&5彩虹混凝土 &7(圣诞节版)", "", CHRISTMAS); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_XMAS = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_XMAS", Material.WHITE_GLAZED_TERRACOTTA, "&5彩虹带釉陶瓦 &7(圣诞节版)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_WOOL_XMAS = + new SlimefunItemStack("RAINBOW_WOOL_XMAS", Material.WHITE_WOOL, "&5彩虹羊毛 &7(圣诞节版)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_GLASS_XMAS = + new SlimefunItemStack("RAINBOW_GLASS_XMAS", Material.WHITE_STAINED_GLASS, "&5彩虹玻璃 &7(圣诞节版)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_CLAY_XMAS = + new SlimefunItemStack("RAINBOW_CLAY_XMAS", Material.WHITE_TERRACOTTA, "&5彩虹粘土块 &7(圣诞节版)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_GLASS_PANE_XMAS = new SlimefunItemStack( + "RAINBOW_GLASS_PANE_XMAS", Material.WHITE_STAINED_GLASS_PANE, "&5彩虹玻璃板 &7(圣诞节版)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_CONCRETE_XMAS = + new SlimefunItemStack("RAINBOW_CONCRETE_XMAS", Material.WHITE_CONCRETE, "&5彩虹混凝土 &7(圣诞节版)", "", CHRISTMAS); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_XMAS = new SlimefunItemStack( + "RAINBOW_GLAZED_TERRACOTTA_XMAS", Material.WHITE_GLAZED_TERRACOTTA, "&5彩虹带釉陶瓦 &7(圣诞节版)", "", CHRISTMAS); private static final String VALENTINES_DAY = "&d< 情人节版 >"; - public static final SlimefunItemStack RAINBOW_WOOL_VALENTINE = new SlimefunItemStack("RAINBOW_WOOL_VALENTINE", Material.PINK_WOOL, "&5彩虹羊毛 &7(情人节版)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_GLASS_VALENTINE = new SlimefunItemStack("RAINBOW_GLASS_VALENTINE", Material.PINK_STAINED_GLASS, "&5彩虹玻璃 &7(情人节版)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_CLAY_VALENTINE = new SlimefunItemStack("RAINBOW_CLAY_VALENTINE", Material.PINK_TERRACOTTA, "&5彩虹粘土块 &7(情人节版)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_GLASS_PANE_VALENTINE = new SlimefunItemStack("RAINBOW_GLASS_PANE_VALENTINE", Material.PINK_STAINED_GLASS_PANE, "&5彩虹玻璃板 &7(情人节版)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_CONCRETE_VALENTINE = new SlimefunItemStack("RAINBOW_CONCRETE_VALENTINE", Material.PINK_CONCRETE, "&5彩虹混凝土 &7(情人节版)", "", VALENTINES_DAY); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_VALENTINE = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_VALENTINE", Material.PINK_GLAZED_TERRACOTTA, "&5彩虹带釉陶瓦 &7(情人节版)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_WOOL_VALENTINE = + new SlimefunItemStack("RAINBOW_WOOL_VALENTINE", Material.PINK_WOOL, "&5彩虹羊毛 &7(情人节版)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_GLASS_VALENTINE = new SlimefunItemStack( + "RAINBOW_GLASS_VALENTINE", Material.PINK_STAINED_GLASS, "&5彩虹玻璃 &7(情人节版)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_CLAY_VALENTINE = new SlimefunItemStack( + "RAINBOW_CLAY_VALENTINE", Material.PINK_TERRACOTTA, "&5彩虹粘土块 &7(情人节版)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_GLASS_PANE_VALENTINE = new SlimefunItemStack( + "RAINBOW_GLASS_PANE_VALENTINE", Material.PINK_STAINED_GLASS_PANE, "&5彩虹玻璃板 &7(情人节版)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_CONCRETE_VALENTINE = new SlimefunItemStack( + "RAINBOW_CONCRETE_VALENTINE", Material.PINK_CONCRETE, "&5彩虹混凝土 &7(情人节版)", "", VALENTINES_DAY); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_VALENTINE = new SlimefunItemStack( + "RAINBOW_GLAZED_TERRACOTTA_VALENTINE", + Material.PINK_GLAZED_TERRACOTTA, + "&5彩虹带釉陶瓦 &7(情人节版)", + "", + VALENTINES_DAY); private static final String HALLOWEEN = "&6< 万圣节版 >"; - public static final SlimefunItemStack RAINBOW_WOOL_HALLOWEEN = new SlimefunItemStack("RAINBOW_WOOL_HALLOWEEN", Material.ORANGE_WOOL, "&5彩虹羊毛 &7(万圣节版)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_GLASS_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLASS_HALLOWEEN", Material.ORANGE_STAINED_GLASS, "&5彩虹玻璃 &7(万圣节版)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_CLAY_HALLOWEEN = new SlimefunItemStack("RAINBOW_CLAY_HALLOWEEN", Material.ORANGE_TERRACOTTA, "&5彩虹粘土块 &7(万圣节版)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_GLASS_PANE_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLASS_PANE_HALLOWEEN", Material.ORANGE_STAINED_GLASS_PANE, "&5彩虹玻璃板 &7(万圣节版)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_CONCRETE_HALLOWEEN = new SlimefunItemStack("RAINBOW_CONCRETE_HALLOWEEN", Material.ORANGE_CONCRETE, "&5彩虹混凝土 &7(万圣节版)", "", HALLOWEEN); - public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN = new SlimefunItemStack("RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN", Material.ORANGE_GLAZED_TERRACOTTA, "&5彩虹带釉陶瓦 &7(万圣节版)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_WOOL_HALLOWEEN = + new SlimefunItemStack("RAINBOW_WOOL_HALLOWEEN", Material.ORANGE_WOOL, "&5彩虹羊毛 &7(万圣节版)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_GLASS_HALLOWEEN = new SlimefunItemStack( + "RAINBOW_GLASS_HALLOWEEN", Material.ORANGE_STAINED_GLASS, "&5彩虹玻璃 &7(万圣节版)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_CLAY_HALLOWEEN = new SlimefunItemStack( + "RAINBOW_CLAY_HALLOWEEN", Material.ORANGE_TERRACOTTA, "&5彩虹粘土块 &7(万圣节版)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_GLASS_PANE_HALLOWEEN = new SlimefunItemStack( + "RAINBOW_GLASS_PANE_HALLOWEEN", Material.ORANGE_STAINED_GLASS_PANE, "&5彩虹玻璃板 &7(万圣节版)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_CONCRETE_HALLOWEEN = new SlimefunItemStack( + "RAINBOW_CONCRETE_HALLOWEEN", Material.ORANGE_CONCRETE, "&5彩虹混凝土 &7(万圣节版)", "", HALLOWEEN); + public static final SlimefunItemStack RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN = new SlimefunItemStack( + "RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN", + Material.ORANGE_GLAZED_TERRACOTTA, + "&5彩虹带釉陶瓦 &7(万圣节版)", + "", + HALLOWEEN); /* 锭 */ public static final SlimefunItemStack COPPER_INGOT = new SlimefunItemStack("COPPER_INGOT", Material.BRICK, "&b铜锭"); public static final SlimefunItemStack TIN_INGOT = new SlimefunItemStack("TIN_INGOT", Material.IRON_INGOT, "&b锡锭"); - public static final SlimefunItemStack SILVER_INGOT = new SlimefunItemStack("SILVER_INGOT", Material.IRON_INGOT, "&b银锭"); - public static final SlimefunItemStack ALUMINUM_INGOT = new SlimefunItemStack("ALUMINUM_INGOT", Material.IRON_INGOT, "&b铝锭"); + public static final SlimefunItemStack SILVER_INGOT = + new SlimefunItemStack("SILVER_INGOT", Material.IRON_INGOT, "&b银锭"); + public static final SlimefunItemStack ALUMINUM_INGOT = + new SlimefunItemStack("ALUMINUM_INGOT", Material.IRON_INGOT, "&b铝锭"); public static final SlimefunItemStack LEAD_INGOT = new SlimefunItemStack("LEAD_INGOT", Material.IRON_INGOT, "&b铅锭"); public static final SlimefunItemStack ZINC_INGOT = new SlimefunItemStack("ZINC_INGOT", Material.IRON_INGOT, "&b锌锭"); - public static final SlimefunItemStack MAGNESIUM_INGOT = new SlimefunItemStack("MAGNESIUM_INGOT", Material.IRON_INGOT, "&b镁锭"); + public static final SlimefunItemStack MAGNESIUM_INGOT = + new SlimefunItemStack("MAGNESIUM_INGOT", Material.IRON_INGOT, "&b镁锭"); /* Alloy (Carbon + Iron) */ - public static final SlimefunItemStack STEEL_INGOT = new SlimefunItemStack("STEEL_INGOT", Material.IRON_INGOT, "&b钢锭"); + public static final SlimefunItemStack STEEL_INGOT = + new SlimefunItemStack("STEEL_INGOT", Material.IRON_INGOT, "&b钢锭"); /* Alloy (Copper + Tin) */ public static final SlimefunItemStack BRONZE_INGOT = new SlimefunItemStack("BRONZE_INGOT", Material.BRICK, "&b青铜锭"); /* Alloy (Copper + Aluminum) */ - public static final SlimefunItemStack DURALUMIN_INGOT = new SlimefunItemStack("DURALUMIN_INGOT", Material.IRON_INGOT, "&b硬铝锭"); + public static final SlimefunItemStack DURALUMIN_INGOT = + new SlimefunItemStack("DURALUMIN_INGOT", Material.IRON_INGOT, "&b硬铝锭"); /* Alloy (Copper + Silver) */ - public static final SlimefunItemStack BILLON_INGOT = new SlimefunItemStack("BILLON_INGOT", Material.IRON_INGOT, "&b银铜合金锭"); + public static final SlimefunItemStack BILLON_INGOT = + new SlimefunItemStack("BILLON_INGOT", Material.IRON_INGOT, "&b银铜合金锭"); /* Alloy (Copper + Zinc) */ - public static final SlimefunItemStack BRASS_INGOT = new SlimefunItemStack("BRASS_INGOT", Material.GOLD_INGOT, "&b黄铜锭"); + public static final SlimefunItemStack BRASS_INGOT = + new SlimefunItemStack("BRASS_INGOT", Material.GOLD_INGOT, "&b黄铜锭"); /* Alloy (Aluminum + Brass) */ - public static final SlimefunItemStack ALUMINUM_BRASS_INGOT = new SlimefunItemStack("ALUMINUM_BRASS_INGOT", Material.GOLD_INGOT, "&b铝黄铜锭"); + public static final SlimefunItemStack ALUMINUM_BRASS_INGOT = + new SlimefunItemStack("ALUMINUM_BRASS_INGOT", Material.GOLD_INGOT, "&b铝黄铜锭"); /* Alloy (Aluminum + Bronze) */ - public static final SlimefunItemStack ALUMINUM_BRONZE_INGOT = new SlimefunItemStack("ALUMINUM_BRONZE_INGOT", Material.GOLD_INGOT, "&b铝青铜锭"); + public static final SlimefunItemStack ALUMINUM_BRONZE_INGOT = + new SlimefunItemStack("ALUMINUM_BRONZE_INGOT", Material.GOLD_INGOT, "&b铝青铜锭"); /* Alloy (Gold + Silver + Copper) */ - public static final SlimefunItemStack CORINTHIAN_BRONZE_INGOT = new SlimefunItemStack("CORINTHIAN_BRONZE_INGOT", Material.GOLD_INGOT, "&b科林斯青铜锭"); + public static final SlimefunItemStack CORINTHIAN_BRONZE_INGOT = + new SlimefunItemStack("CORINTHIAN_BRONZE_INGOT", Material.GOLD_INGOT, "&b科林斯青铜锭"); /* Alloy (Lead + Tin) */ - public static final SlimefunItemStack SOLDER_INGOT = new SlimefunItemStack("SOLDER_INGOT", Material.IRON_INGOT, "&b焊锡锭"); + public static final SlimefunItemStack SOLDER_INGOT = + new SlimefunItemStack("SOLDER_INGOT", Material.IRON_INGOT, "&b焊锡锭"); /* Alloy (Steel + Iron + Carbon) */ - public static final SlimefunItemStack DAMASCUS_STEEL_INGOT = new SlimefunItemStack("DAMASCUS_STEEL_INGOT", Material.IRON_INGOT, "&b大马士革钢锭"); + public static final SlimefunItemStack DAMASCUS_STEEL_INGOT = + new SlimefunItemStack("DAMASCUS_STEEL_INGOT", Material.IRON_INGOT, "&b大马士革钢锭"); /* Alloy (大马士革钢 + 硬铝 + Compressed Carbon + Aluminium Bronze) */ - public static final SlimefunItemStack HARDENED_METAL_INGOT = new SlimefunItemStack("HARDENED_METAL_INGOT", Material.IRON_INGOT, "&b&l硬化金属"); + public static final SlimefunItemStack HARDENED_METAL_INGOT = + new SlimefunItemStack("HARDENED_METAL_INGOT", Material.IRON_INGOT, "&b&l硬化金属"); /* Alloy (Hardened Metal + Corinthian Bronze + Solder + Billon + 大马士革钢) */ - public static final SlimefunItemStack REINFORCED_ALLOY_INGOT = new SlimefunItemStack("REINFORCED_ALLOY_INGOT", Material.IRON_INGOT, "&b&l强化合金锭"); + public static final SlimefunItemStack REINFORCED_ALLOY_INGOT = + new SlimefunItemStack("REINFORCED_ALLOY_INGOT", Material.IRON_INGOT, "&b&l强化合金锭"); /* Alloy (Iron + Silicon) */ - public static final SlimefunItemStack FERROSILICON = new SlimefunItemStack("FERROSILICON", Material.IRON_INGOT, "&b硅铁"); + public static final SlimefunItemStack FERROSILICON = + new SlimefunItemStack("FERROSILICON", Material.IRON_INGOT, "&b硅铁"); /* Alloy (Iron + Gold) */ - public static final SlimefunItemStack GILDED_IRON = new SlimefunItemStack("GILDED_IRON", Material.GOLD_INGOT, "&6&l镀金铁锭"); + public static final SlimefunItemStack GILDED_IRON = + new SlimefunItemStack("GILDED_IRON", Material.GOLD_INGOT, "&6&l镀金铁锭"); /* Alloy (Redstone + Ferrosilicon) */ - public static final SlimefunItemStack REDSTONE_ALLOY = new SlimefunItemStack("REDSTONE_ALLOY", Material.BRICK, "&c红石合金锭"); + public static final SlimefunItemStack REDSTONE_ALLOY = + new SlimefunItemStack("REDSTONE_ALLOY", Material.BRICK, "&c红石合金锭"); /* Alloy (Iron + Copper) */ - public static final SlimefunItemStack NICKEL_INGOT = new SlimefunItemStack("NICKEL_INGOT", Material.IRON_INGOT, "&b镍锭"); + public static final SlimefunItemStack NICKEL_INGOT = + new SlimefunItemStack("NICKEL_INGOT", Material.IRON_INGOT, "&b镍锭"); /* Alloy (Nickel + Iron + Copper) */ - public static final SlimefunItemStack COBALT_INGOT = new SlimefunItemStack("COBALT_INGOT", Material.IRON_INGOT, "&9钴锭"); + public static final SlimefunItemStack COBALT_INGOT = + new SlimefunItemStack("COBALT_INGOT", Material.IRON_INGOT, "&9钴锭"); /* Gold */ - public static final SlimefunItemStack GOLD_4K = new SlimefunItemStack("GOLD_4K", Material.GOLD_INGOT, "&r金锭 &7(4克拉)"); - public static final SlimefunItemStack GOLD_6K = new SlimefunItemStack("GOLD_6K", Material.GOLD_INGOT, "&r金锭 &7(6克拉)"); - public static final SlimefunItemStack GOLD_8K = new SlimefunItemStack("GOLD_8K", Material.GOLD_INGOT, "&r金锭 &7(8克拉)"); - public static final SlimefunItemStack GOLD_10K = new SlimefunItemStack("GOLD_10K", Material.GOLD_INGOT, "&r金锭 &7(10克拉)"); - public static final SlimefunItemStack GOLD_12K = new SlimefunItemStack("GOLD_12K", Material.GOLD_INGOT, "&r金锭 &7(12克拉)"); - public static final SlimefunItemStack GOLD_14K = new SlimefunItemStack("GOLD_14K", Material.GOLD_INGOT, "&r金锭 &7(14克拉)"); - public static final SlimefunItemStack GOLD_16K = new SlimefunItemStack("GOLD_16K", Material.GOLD_INGOT, "&r金锭 &7(16克拉)"); - public static final SlimefunItemStack GOLD_18K = new SlimefunItemStack("GOLD_18K", Material.GOLD_INGOT, "&r金锭 &7(18克拉)"); - public static final SlimefunItemStack GOLD_20K = new SlimefunItemStack("GOLD_20K", Material.GOLD_INGOT, "&r金锭 &7(20克拉)"); - public static final SlimefunItemStack GOLD_22K = new SlimefunItemStack("GOLD_22K", Material.GOLD_INGOT, "&r金锭 &7(22克拉)"); - public static final SlimefunItemStack GOLD_24K = new SlimefunItemStack("GOLD_24K", Material.GOLD_INGOT, "&r金锭 &7(24克拉)"); + public static final SlimefunItemStack GOLD_4K = + new SlimefunItemStack("GOLD_4K", Material.GOLD_INGOT, "&r金锭 &7(4克拉)"); + public static final SlimefunItemStack GOLD_6K = + new SlimefunItemStack("GOLD_6K", Material.GOLD_INGOT, "&r金锭 &7(6克拉)"); + public static final SlimefunItemStack GOLD_8K = + new SlimefunItemStack("GOLD_8K", Material.GOLD_INGOT, "&r金锭 &7(8克拉)"); + public static final SlimefunItemStack GOLD_10K = + new SlimefunItemStack("GOLD_10K", Material.GOLD_INGOT, "&r金锭 &7(10克拉)"); + public static final SlimefunItemStack GOLD_12K = + new SlimefunItemStack("GOLD_12K", Material.GOLD_INGOT, "&r金锭 &7(12克拉)"); + public static final SlimefunItemStack GOLD_14K = + new SlimefunItemStack("GOLD_14K", Material.GOLD_INGOT, "&r金锭 &7(14克拉)"); + public static final SlimefunItemStack GOLD_16K = + new SlimefunItemStack("GOLD_16K", Material.GOLD_INGOT, "&r金锭 &7(16克拉)"); + public static final SlimefunItemStack GOLD_18K = + new SlimefunItemStack("GOLD_18K", Material.GOLD_INGOT, "&r金锭 &7(18克拉)"); + public static final SlimefunItemStack GOLD_20K = + new SlimefunItemStack("GOLD_20K", Material.GOLD_INGOT, "&r金锭 &7(20克拉)"); + public static final SlimefunItemStack GOLD_22K = + new SlimefunItemStack("GOLD_22K", Material.GOLD_INGOT, "&r金锭 &7(22克拉)"); + public static final SlimefunItemStack GOLD_24K = + new SlimefunItemStack("GOLD_24K", Material.GOLD_INGOT, "&r金锭 &7(24克拉)"); /* Dusts */ public static final SlimefunItemStack IRON_DUST = new SlimefunItemStack("IRON_DUST", Material.GUNPOWDER, "&6铁粉"); - public static final SlimefunItemStack GOLD_DUST = new SlimefunItemStack("GOLD_DUST", Material.GLOWSTONE_DUST, "&6金粉"); + public static final SlimefunItemStack GOLD_DUST = + new SlimefunItemStack("GOLD_DUST", Material.GLOWSTONE_DUST, "&6金粉"); public static final SlimefunItemStack TIN_DUST = new SlimefunItemStack("TIN_DUST", Material.SUGAR, "&6锡粉"); - public static final SlimefunItemStack COPPER_DUST = new SlimefunItemStack("COPPER_DUST", Material.GLOWSTONE_DUST, "&6铜粉"); + public static final SlimefunItemStack COPPER_DUST = + new SlimefunItemStack("COPPER_DUST", Material.GLOWSTONE_DUST, "&6铜粉"); public static final SlimefunItemStack SILVER_DUST = new SlimefunItemStack("SILVER_DUST", Material.SUGAR, "&6银粉"); - public static final SlimefunItemStack ALUMINUM_DUST = new SlimefunItemStack("ALUMINUM_DUST", Material.SUGAR, "&6铝粉"); + public static final SlimefunItemStack ALUMINUM_DUST = + new SlimefunItemStack("ALUMINUM_DUST", Material.SUGAR, "&6铝粉"); public static final SlimefunItemStack LEAD_DUST = new SlimefunItemStack("LEAD_DUST", Material.GUNPOWDER, "&6铅粉"); public static final SlimefunItemStack SULFATE = new SlimefunItemStack("SULFATE", Material.GLOWSTONE_DUST, "&6硫酸盐"); public static final SlimefunItemStack ZINC_DUST = new SlimefunItemStack("ZINC_DUST", Material.SUGAR, "&6锌粉"); - public static final SlimefunItemStack MAGNESIUM_DUST = new SlimefunItemStack("MAGNESIUM_DUST", Material.SUGAR, "&6镁粉"); + public static final SlimefunItemStack MAGNESIUM_DUST = + new SlimefunItemStack("MAGNESIUM_DUST", Material.SUGAR, "&6镁粉"); public static final SlimefunItemStack SILICON = new SlimefunItemStack("SILICON", Material.FIREWORK_STAR, "&6硅"); - public static final SlimefunItemStack GOLD_24K_BLOCK = new SlimefunItemStack("GOLD_24K_BLOCK", Material.GOLD_BLOCK, "&r&r金块 &7(24克拉)"); + public static final SlimefunItemStack GOLD_24K_BLOCK = + new SlimefunItemStack("GOLD_24K_BLOCK", Material.GOLD_BLOCK, "&r&r金块 &7(24克拉)"); /* Gems */ - public static final SlimefunItemStack SYNTHETIC_DIAMOND = new SlimefunItemStack("SYNTHETIC_DIAMOND", Material.DIAMOND, "&b人造钻石", "", "&r可以在工作台中作为钻石使用"); - public static final SlimefunItemStack SYNTHETIC_EMERALD = new SlimefunItemStack("SYNTHETIC_EMERALD", Material.EMERALD, "&b人造绿宝石", "", "&r可以用来和村民交易"); - public static final SlimefunItemStack SYNTHETIC_SAPPHIRE = new SlimefunItemStack("SYNTHETIC_SAPPHIRE", HeadTexture.SAPPHIRE, "&b人造蓝宝石", "", "&r可以在工作台中作为青金石使用"); - public static final SlimefunItemStack CARBONADO = new SlimefunItemStack("CARBONADO", HeadTexture.CARBONADO, "&b&l黑金刚石", "", "&7&o\"黑色钻石\""); - public static final SlimefunItemStack RAW_CARBONADO = new SlimefunItemStack("RAW_CARBONADO", HeadTexture.RAW_CARBONADO, "&b黑金刚石原矿"); - - public static final SlimefunItemStack URANIUM = new SlimefunItemStack("URANIUM", HeadTexture.URANIUM, "&4铀", "", LoreBuilder.radioactive(Radioactivity.HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack NEPTUNIUM = new SlimefunItemStack("NEPTUNIUM", HeadTexture.NEPTUNIUM, "&a镎", "", LoreBuilder.radioactive(Radioactivity.HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack PLUTONIUM = new SlimefunItemStack("PLUTONIUM", HeadTexture.PLUTONIUM, "&7钚", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack BOOSTED_URANIUM = new SlimefunItemStack("BOOSTED_URANIUM", HeadTexture.BOOSTED_URANIUM, "&2钚铀混合氧化物核燃料", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack SYNTHETIC_DIAMOND = + new SlimefunItemStack("SYNTHETIC_DIAMOND", Material.DIAMOND, "&b人造钻石", "", "&r可以在工作台中作为钻石使用"); + public static final SlimefunItemStack SYNTHETIC_EMERALD = + new SlimefunItemStack("SYNTHETIC_EMERALD", Material.EMERALD, "&b人造绿宝石", "", "&r可以用来和村民交易"); + public static final SlimefunItemStack SYNTHETIC_SAPPHIRE = + new SlimefunItemStack("SYNTHETIC_SAPPHIRE", HeadTexture.SAPPHIRE, "&b人造蓝宝石", "", "&r可以在工作台中作为青金石使用"); + public static final SlimefunItemStack CARBONADO = + new SlimefunItemStack("CARBONADO", HeadTexture.CARBONADO, "&b&l黑金刚石", "", "&7&o\"黑色钻石\""); + public static final SlimefunItemStack RAW_CARBONADO = + new SlimefunItemStack("RAW_CARBONADO", HeadTexture.RAW_CARBONADO, "&b黑金刚石原矿"); + + public static final SlimefunItemStack URANIUM = new SlimefunItemStack( + "URANIUM", + HeadTexture.URANIUM, + "&4铀", + "", + LoreBuilder.radioactive(Radioactivity.HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack NEPTUNIUM = new SlimefunItemStack( + "NEPTUNIUM", + HeadTexture.NEPTUNIUM, + "&a镎", + "", + LoreBuilder.radioactive(Radioactivity.HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack PLUTONIUM = new SlimefunItemStack( + "PLUTONIUM", + HeadTexture.PLUTONIUM, + "&7钚", + "", + LoreBuilder.radioactive(Radioactivity.VERY_HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack BOOSTED_URANIUM = new SlimefunItemStack( + "BOOSTED_URANIUM", + HeadTexture.BOOSTED_URANIUM, + "&2钚铀混合氧化物核燃料", + "", + LoreBuilder.radioactive(Radioactivity.VERY_HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); /* Talisman */ - public static final SlimefunItemStack COMMON_TALISMAN = new SlimefunItemStack("COMMON_TALISMAN", Material.EMERALD, "&6普通护身符"); - public static final SlimefunItemStack ENDER_TALISMAN = new SlimefunItemStack("ENDER_TALISMAN", Material.EMERALD, "&5末影护身符"); - - public static final SlimefunItemStack TALISMAN_ANVIL = new SlimefunItemStack("ANVIL_TALISMAN", Material.EMERALD, "&a铁砧护身符", "", "&f每个护身符可以防止", "&f一个工具因耐久不足而损坏", "&f然后就会被消耗", "", "&4&l警告:", "&4由于过于强大的工具的复杂性", "&4此护身符不能修复过于强大的工具"); - public static final SlimefunItemStack TALISMAN_MINER = new SlimefunItemStack("MINER_TALISMAN", Material.EMERALD, "&a矿工护身符", "", "&f当这个护身符在你的背包里时", "&f将有 20% 的几率双倍掉落", "&f你挖出的矿物"); - public static final SlimefunItemStack TALISMAN_FARMER = new SlimefunItemStack("FARMER_TALISMAN", Material.EMERALD, "&a农夫护身符", "", "&f当这个护身符在你的背包里时", "&f将有 20% 的几率双倍掉落", "&f你收割的农作物"); - public static final SlimefunItemStack TALISMAN_HUNTER = new SlimefunItemStack("HUNTER_TALISMAN", Material.EMERALD, "&a猎人护身符", "", "&f当这个护身符在你的背包里时", "&f将有 20% 的几率双倍掉落", "&f你杀死的生物的掉落物"); - public static final SlimefunItemStack TALISMAN_LAVA = new SlimefunItemStack("LAVA_TALISMAN", Material.EMERALD, "&a岩浆行者护身符", "", "&f当这个护身符在你的背包里时", "&f获得火焰保护效果", "&f仅在你行走在岩浆上时可用", "&f然后就会被消耗"); - public static final SlimefunItemStack TALISMAN_WATER = new SlimefunItemStack("WATER_TALISMAN", Material.EMERALD, "&a潜水者护身符", "", "&f当这个护身符在你的背包里时", "&f一旦你即将溺水而死", "&f护身符将会给予你水下呼吸", "&f然后就会被消耗"); - public static final SlimefunItemStack TALISMAN_ANGEL = new SlimefunItemStack("ANGEL_TALISMAN", Material.EMERALD, "&a天使护身符", "", "&f当这个护身符在你的背包里时", "&f有 75% 的几率减免你的摔落伤害"); - public static final SlimefunItemStack TALISMAN_FIRE = new SlimefunItemStack("FIRE_TALISMAN", Material.EMERALD, "&a消防员护身符", "", "&f当这个护身符在你的背包里时", "&f在你着火时", "&f给予你防火效果", "&f然后就会被消耗"); - public static final SlimefunItemStack TALISMAN_MAGICIAN = new SlimefunItemStack("MAGICIAN_TALISMAN", Material.EMERALD, "&a魔法师护身符", "", "&f当这个护身符在你的背包里时", "&f在附魔时有 80% 的几率", "&f得到一个额外的附魔"); - public static final SlimefunItemStack TALISMAN_TRAVELLER = new SlimefunItemStack("TRAVELLER_TALISMAN", Material.EMERALD, "&a旅行者护身符", "", "&f当这个护身符在你的背包里时", "&f在你开始疾跑时有 60% 的几率", "&f给予你速度效果"); - public static final SlimefunItemStack TALISMAN_WARRIOR = new SlimefunItemStack("WARRIOR_TALISMAN", Material.EMERALD, "&a战士护身符", "", "&f当这个护身符在你的背包里时", "&f你被攻击后将会获得力量3的效果", "&f然后就会被消耗"); - public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack("KNIGHT_TALISMAN", Material.EMERALD, "&a骑士护身符", "", "&f当这个护身符在你的背包里时", "&f在你被攻击后", "&f有 30% 的几率获得五秒的生命恢复", "&f然后就会被消耗"); - public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack("WHIRLWIND_TALISMAN", Material.EMERALD, "&a旋风护身符", "", "&f当这个护身符在你的背包里时", "&f将有 60% 的几率", "&f反弹所有冲向你的弹射物"); - public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack("WIZARD_TALISMAN", Material.EMERALD, "&a巫师护身符", "", "&f当这个护身符在你的背包里时", "&f在你附魔时可获得时运4/5", "&f但它也可能降低该物品", "&f其他附魔的等级"); - public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack("CAVEMAN_TALISMAN", Material.EMERALD, "&a穴居人护身符", "", "&f当这个护身符在你的背包里时", "&f在你挖矿时有 50% 的几率", "&f获得片刻的急迫效果"); - public static final SlimefunItemStack TALISMAN_WISE = new SlimefunItemStack("WISE_TALISMAN", Material.EMERALD, "&a智者的护身符", "", "&f当这个护身符在你的背包里时", "&f获得的经验将有 20% 的几率变为双倍"); + public static final SlimefunItemStack COMMON_TALISMAN = + new SlimefunItemStack("COMMON_TALISMAN", Material.EMERALD, "&6普通护身符"); + public static final SlimefunItemStack ENDER_TALISMAN = + new SlimefunItemStack("ENDER_TALISMAN", Material.EMERALD, "&5末影护身符"); + + public static final SlimefunItemStack TALISMAN_ANVIL = new SlimefunItemStack( + "ANVIL_TALISMAN", + Material.EMERALD, + "&a铁砧护身符", + "", + "&f每个护身符可以防止", + "&f一个工具因耐久不足而损坏", + "&f然后就会被消耗", + "", + "&4&l警告:", + "&4由于过于强大的工具的复杂性", + "&4此护身符不能修复过于强大的工具"); + public static final SlimefunItemStack TALISMAN_MINER = new SlimefunItemStack( + "MINER_TALISMAN", Material.EMERALD, "&a矿工护身符", "", "&f当这个护身符在你的背包里时", "&f将有 20% 的几率双倍掉落", "&f你挖出的矿物"); + public static final SlimefunItemStack TALISMAN_FARMER = new SlimefunItemStack( + "FARMER_TALISMAN", Material.EMERALD, "&a农夫护身符", "", "&f当这个护身符在你的背包里时", "&f将有 20% 的几率双倍掉落", "&f你收割的农作物"); + public static final SlimefunItemStack TALISMAN_HUNTER = new SlimefunItemStack( + "HUNTER_TALISMAN", Material.EMERALD, "&a猎人护身符", "", "&f当这个护身符在你的背包里时", "&f将有 20% 的几率双倍掉落", "&f你杀死的生物的掉落物"); + public static final SlimefunItemStack TALISMAN_LAVA = new SlimefunItemStack( + "LAVA_TALISMAN", + Material.EMERALD, + "&a岩浆行者护身符", + "", + "&f当这个护身符在你的背包里时", + "&f获得火焰保护效果", + "&f仅在你行走在岩浆上时可用", + "&f然后就会被消耗"); + public static final SlimefunItemStack TALISMAN_WATER = new SlimefunItemStack( + "WATER_TALISMAN", + Material.EMERALD, + "&a潜水者护身符", + "", + "&f当这个护身符在你的背包里时", + "&f一旦你即将溺水而死", + "&f护身符将会给予你水下呼吸", + "&f然后就会被消耗"); + public static final SlimefunItemStack TALISMAN_ANGEL = new SlimefunItemStack( + "ANGEL_TALISMAN", Material.EMERALD, "&a天使护身符", "", "&f当这个护身符在你的背包里时", "&f有 75% 的几率减免你的摔落伤害"); + public static final SlimefunItemStack TALISMAN_FIRE = new SlimefunItemStack( + "FIRE_TALISMAN", Material.EMERALD, "&a消防员护身符", "", "&f当这个护身符在你的背包里时", "&f在你着火时", "&f给予你防火效果", "&f然后就会被消耗"); + public static final SlimefunItemStack TALISMAN_MAGICIAN = new SlimefunItemStack( + "MAGICIAN_TALISMAN", Material.EMERALD, "&a魔法师护身符", "", "&f当这个护身符在你的背包里时", "&f在附魔时有 80% 的几率", "&f得到一个额外的附魔"); + public static final SlimefunItemStack TALISMAN_TRAVELLER = new SlimefunItemStack( + "TRAVELLER_TALISMAN", + Material.EMERALD, + "&a旅行者护身符", + "", + "&f当这个护身符在你的背包里时", + "&f在你开始疾跑时有 60% 的几率", + "&f给予你速度效果"); + public static final SlimefunItemStack TALISMAN_WARRIOR = new SlimefunItemStack( + "WARRIOR_TALISMAN", Material.EMERALD, "&a战士护身符", "", "&f当这个护身符在你的背包里时", "&f你被攻击后将会获得力量3的效果", "&f然后就会被消耗"); + public static final SlimefunItemStack TALISMAN_KNIGHT = new SlimefunItemStack( + "KNIGHT_TALISMAN", + Material.EMERALD, + "&a骑士护身符", + "", + "&f当这个护身符在你的背包里时", + "&f在你被攻击后", + "&f有 30% 的几率获得五秒的生命恢复", + "&f然后就会被消耗"); + public static final SlimefunItemStack TALISMAN_WHIRLWIND = new SlimefunItemStack( + "WHIRLWIND_TALISMAN", Material.EMERALD, "&a旋风护身符", "", "&f当这个护身符在你的背包里时", "&f将有 60% 的几率", "&f反弹所有冲向你的弹射物"); + public static final SlimefunItemStack TALISMAN_WIZARD = new SlimefunItemStack( + "WIZARD_TALISMAN", + Material.EMERALD, + "&a巫师护身符", + "", + "&f当这个护身符在你的背包里时", + "&f在你附魔时可获得时运4/5", + "&f但它也可能降低该物品", + "&f其他附魔的等级"); + public static final SlimefunItemStack TALISMAN_CAVEMAN = new SlimefunItemStack( + "CAVEMAN_TALISMAN", Material.EMERALD, "&a穴居人护身符", "", "&f当这个护身符在你的背包里时", "&f在你挖矿时有 50% 的几率", "&f获得片刻的急迫效果"); + public static final SlimefunItemStack TALISMAN_WISE = new SlimefunItemStack( + "WISE_TALISMAN", Material.EMERALD, "&a智者的护身符", "", "&f当这个护身符在你的背包里时", "&f获得的经验将有 20% 的几率变为双倍"); /* Staves */ - public static final SlimefunItemStack STAFF_ELEMENTAL = new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6元素法杖"); - public static final SlimefunItemStack STAFF_WIND = new SlimefunItemStack("STAFF_ELEMENTAL_WIND", Material.STICK, "&6元素法杖 &7- &b&o风", "", "&7元素: &b&o风", "", "&7&e右键&7 以将你吹飞"); - public static final SlimefunItemStack STAFF_FIRE = new SlimefunItemStack("STAFF_ELEMENTAL_FIRE", Material.STICK, "&6元素法杖 &7- &c&o火", "", "&7元素: &c&o火", "", "&c让火焰净化一切!"); - public static final SlimefunItemStack STAFF_WATER = new SlimefunItemStack("STAFF_ELEMENTAL_WATER", Material.STICK, "&6元素法杖 &7- &1&o水", "", "&7元素: &1&o水", "", "&7&e右键&7 以灭掉你身上的火"); - public static final SlimefunItemStack STAFF_STORM = new SlimefunItemStack("STAFF_ELEMENTAL_STORM", Material.STICK, "&6元素法杖 &7- &8&o雷", "", "&7元素: &8&o雷", "", "&e右键&7 召唤一道闪电", LoreBuilder.usesLeft(StormStaff.MAX_USES)); + public static final SlimefunItemStack STAFF_ELEMENTAL = + new SlimefunItemStack("STAFF_ELEMENTAL", Material.STICK, "&6元素法杖"); + public static final SlimefunItemStack STAFF_WIND = new SlimefunItemStack( + "STAFF_ELEMENTAL_WIND", Material.STICK, "&6元素法杖 &7- &b&o风", "", "&7元素: &b&o风", "", "&7&e右键&7 以将你吹飞"); + public static final SlimefunItemStack STAFF_FIRE = new SlimefunItemStack( + "STAFF_ELEMENTAL_FIRE", Material.STICK, "&6元素法杖 &7- &c&o火", "", "&7元素: &c&o火", "", "&c让火焰净化一切!"); + public static final SlimefunItemStack STAFF_WATER = new SlimefunItemStack( + "STAFF_ELEMENTAL_WATER", Material.STICK, "&6元素法杖 &7- &1&o水", "", "&7元素: &1&o水", "", "&7&e右键&7 以灭掉你身上的火"); + public static final SlimefunItemStack STAFF_STORM = new SlimefunItemStack( + "STAFF_ELEMENTAL_STORM", + Material.STICK, + "&6元素法杖 &7- &8&o雷", + "", + "&7元素: &8&o雷", + "", + "&e右键&7 召唤一道闪电", + LoreBuilder.usesLeft(StormStaff.MAX_USES)); static { STAFF_WIND.addUnsafeEnchantment(Enchantment.LUCK, 1); @@ -568,25 +1408,58 @@ private SlimefunItems() { } /* Machines */ - public static final SlimefunItemStack GRIND_STONE = new SlimefunItemStack("GRIND_STONE", Material.DISPENSER, "&b磨石", "", "&a&o更高效的磨物品"); - public static final SlimefunItemStack ARMOR_FORGE = new SlimefunItemStack("ARMOR_FORGE", Material.ANVIL, "&6盔甲锻造台", "", "&a&o给你创造强大防具的力量"); - public static final SlimefunItemStack MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.BLAST_FURNACE, "&e简易冶炼炉", "", "&r简易版的冶炼炉", "&r只能将矿物粉末熔炼成锭"); - public static final SlimefunItemStack SMELTERY = new SlimefunItemStack("SMELTERY", Material.FURNACE, "&6冶炼炉", "", "&a能够冶炼金属的高温炉"); - public static final SlimefunItemStack IGNITION_CHAMBER = new SlimefunItemStack("IGNITION_CHAMBER", Material.DROPPER, "&4自动点火机", "&r以防你的冶炼炉失去火焰", "&r把打火石放入后", "&r放置于冶炼炉的发射器旁边"); - public static final SlimefunItemStack ORE_CRUSHER = new SlimefunItemStack("ORE_CRUSHER", Material.DISPENSER, "&b矿石粉碎机", "", "&a&o粉碎矿石并且得到双倍的矿粉"); - public static final SlimefunItemStack COMPRESSOR = new SlimefunItemStack("COMPRESSOR", Material.PISTON, "&b压缩机", "", "&a压缩物品"); - public static final SlimefunItemStack PRESSURE_CHAMBER = new SlimefunItemStack("PRESSURE_CHAMBER", Material.GLASS, "&b压力机", "", "&a压缩更多的物品"); - public static final SlimefunItemStack MAGIC_WORKBENCH = new SlimefunItemStack("MAGIC_WORKBENCH", Material.CRAFTING_TABLE, "&6魔法工作台", "", "&d给物品注入魔法能量"); - public static final SlimefunItemStack ORE_WASHER = new SlimefunItemStack("ORE_WASHER", Material.CAULDRON, "&6洗矿机", "", "&a&o清洗筛矿变成过滤矿石", "&a&o并且给你一些小石块"); - public static final SlimefunItemStack TABLE_SAW = new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6台锯", "", "&a&o从1个木头里获得8个木板", "&a&o(支持所有的原木)"); + public static final SlimefunItemStack GRIND_STONE = + new SlimefunItemStack("GRIND_STONE", Material.DISPENSER, "&b磨石", "", "&a&o更高效的磨物品"); + public static final SlimefunItemStack ARMOR_FORGE = + new SlimefunItemStack("ARMOR_FORGE", Material.ANVIL, "&6盔甲锻造台", "", "&a&o给你创造强大防具的力量"); + public static final SlimefunItemStack MAKESHIFT_SMELTERY = new SlimefunItemStack( + "MAKESHIFT_SMELTERY", Material.BLAST_FURNACE, "&e简易冶炼炉", "", "&r简易版的冶炼炉", "&r只能将矿物粉末熔炼成锭"); + public static final SlimefunItemStack SMELTERY = + new SlimefunItemStack("SMELTERY", Material.FURNACE, "&6冶炼炉", "", "&a能够冶炼金属的高温炉"); + public static final SlimefunItemStack IGNITION_CHAMBER = new SlimefunItemStack( + "IGNITION_CHAMBER", Material.DROPPER, "&4自动点火机", "&r以防你的冶炼炉失去火焰", "&r把打火石放入后", "&r放置于冶炼炉的发射器旁边"); + public static final SlimefunItemStack ORE_CRUSHER = + new SlimefunItemStack("ORE_CRUSHER", Material.DISPENSER, "&b矿石粉碎机", "", "&a&o粉碎矿石并且得到双倍的矿粉"); + public static final SlimefunItemStack COMPRESSOR = + new SlimefunItemStack("COMPRESSOR", Material.PISTON, "&b压缩机", "", "&a压缩物品"); + public static final SlimefunItemStack PRESSURE_CHAMBER = + new SlimefunItemStack("PRESSURE_CHAMBER", Material.GLASS, "&b压力机", "", "&a压缩更多的物品"); + public static final SlimefunItemStack MAGIC_WORKBENCH = + new SlimefunItemStack("MAGIC_WORKBENCH", Material.CRAFTING_TABLE, "&6魔法工作台", "", "&d给物品注入魔法能量"); + public static final SlimefunItemStack ORE_WASHER = + new SlimefunItemStack("ORE_WASHER", Material.CAULDRON, "&6洗矿机", "", "&a&o清洗筛矿变成过滤矿石", "&a&o并且给你一些小石块"); + public static final SlimefunItemStack TABLE_SAW = + new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6台锯", "", "&a&o从1个木头里获得8个木板", "&a&o(支持所有的原木)"); ; - public static final SlimefunItemStack COMPOSTER = new SlimefunItemStack("COMPOSTER", Material.CAULDRON, "&a搅拌机", "", "&a&o随着时间的推移可以转换各种材料..."); - public static final SlimefunItemStack ENHANCED_CRAFTING_TABLE = new SlimefunItemStack("ENHANCED_CRAFTING_TABLE", Material.CRAFTING_TABLE, "&e增强型工作台", "", "&a&o一个原始的工作台", "&a&o无法承受强大的力量..."); - public static final SlimefunItemStack CRUCIBLE = new SlimefunItemStack("CRUCIBLE", Material.CAULDRON, "&c坩埚", "", "&a&o用来把物品变为液体"); - public static final SlimefunItemStack JUICER = new SlimefunItemStack("JUICER", Material.GLASS_BOTTLE, "&a榨汁机", "", "&a让你创造美味的果汁"); - - public static final SlimefunItemStack INDUSTRIAL_MINER = new SlimefunItemStack("INDUSTRIAL_MINER", Material.GOLDEN_PICKAXE, "&b工业矿机", "", "&r工业矿机能够开采其下方 7x7", "&r的范围内的所有矿物.", "&r将煤炭或其他燃料放入", "&r机器的箱子中为它添加燃料."); - public static final SlimefunItemStack ADVANCED_INDUSTRIAL_MINER = new SlimefunItemStack("ADVANCED_INDUSTRIAL_MINER", Material.DIAMOND_PICKAXE, "&c进阶工业矿机", "", "&r进阶工业矿机能够开采其下方 11x11", "&r的范围中的所有矿物.", "&r将燃油或岩浆放入机器的箱子中", "&r为它添加燃料.", "", "&a+ 精准采集"); + public static final SlimefunItemStack COMPOSTER = + new SlimefunItemStack("COMPOSTER", Material.CAULDRON, "&a搅拌机", "", "&a&o随着时间的推移可以转换各种材料..."); + public static final SlimefunItemStack ENHANCED_CRAFTING_TABLE = new SlimefunItemStack( + "ENHANCED_CRAFTING_TABLE", Material.CRAFTING_TABLE, "&e增强型工作台", "", "&a&o一个原始的工作台", "&a&o无法承受强大的力量..."); + public static final SlimefunItemStack CRUCIBLE = + new SlimefunItemStack("CRUCIBLE", Material.CAULDRON, "&c坩埚", "", "&a&o用来把物品变为液体"); + public static final SlimefunItemStack JUICER = + new SlimefunItemStack("JUICER", Material.GLASS_BOTTLE, "&a榨汁机", "", "&a让你创造美味的果汁"); + + public static final SlimefunItemStack INDUSTRIAL_MINER = new SlimefunItemStack( + "INDUSTRIAL_MINER", + Material.GOLDEN_PICKAXE, + "&b工业矿机", + "", + "&r工业矿机能够开采其下方 7x7", + "&r的范围内的所有矿物.", + "&r将煤炭或其他燃料放入", + "&r机器的箱子中为它添加燃料."); + public static final SlimefunItemStack ADVANCED_INDUSTRIAL_MINER = new SlimefunItemStack( + "ADVANCED_INDUSTRIAL_MINER", + Material.DIAMOND_PICKAXE, + "&c进阶工业矿机", + "", + "&r进阶工业矿机能够开采其下方 11x11", + "&r的范围中的所有矿物.", + "&r将燃油或岩浆放入机器的箱子中", + "&r为它添加燃料.", + "", + "&a+ 精准采集"); static { ItemMeta meta = INDUSTRIAL_MINER.getItemMeta(); @@ -598,276 +1471,1309 @@ private SlimefunItems() { ADVANCED_INDUSTRIAL_MINER.setItemMeta(meta2); } - public static final SlimefunItemStack SOLAR_PANEL = new SlimefunItemStack("SOLAR_PANEL", Material.DAYLIGHT_DETECTOR, "&b光伏电池", "", "&7用于合成 &b太阳能发电机 &7的重要零件"); + public static final SlimefunItemStack SOLAR_PANEL = + new SlimefunItemStack("SOLAR_PANEL", Material.DAYLIGHT_DETECTOR, "&b光伏电池", "", "&7用于合成 &b太阳能发电机 &7的重要零件"); - public static final SlimefunItemStack AUTOMATED_PANNING_MACHINE = new SlimefunItemStack("AUTOMATED_PANNING_MACHINE", Material.BOWL, "&a自动淘金机", "", "&a&o升级版淘金筛"); - public static final SlimefunItemStack OUTPUT_CHEST = new SlimefunItemStack("OUTPUT_CHEST", Material.CHEST, "&4物品输出箱", "", "&c&o将它放在基础机械的发射器旁边", "&c&o做出的物品会放入箱子里面"); - public static final SlimefunItemStack HOLOGRAM_PROJECTOR = new SlimefunItemStack("HOLOGRAM_PROJECTOR", Material.QUARTZ_SLAB, "&b全息投影仪", "", "&r投影出可编辑的全息文字"); + public static final SlimefunItemStack AUTOMATED_PANNING_MACHINE = + new SlimefunItemStack("AUTOMATED_PANNING_MACHINE", Material.BOWL, "&a自动淘金机", "", "&a&o升级版淘金筛"); + public static final SlimefunItemStack OUTPUT_CHEST = new SlimefunItemStack( + "OUTPUT_CHEST", Material.CHEST, "&4物品输出箱", "", "&c&o将它放在基础机械的发射器旁边", "&c&o做出的物品会放入箱子里面"); + public static final SlimefunItemStack HOLOGRAM_PROJECTOR = + new SlimefunItemStack("HOLOGRAM_PROJECTOR", Material.QUARTZ_SLAB, "&b全息投影仪", "", "&r投影出可编辑的全息文字"); /* Enhanced Furnaces */ - public static final SlimefunItemStack ENHANCED_FURNACE = new SlimefunItemStack("ENHANCED_FURNACE", Material.FURNACE, "&7强化熔炉 - &eI", "", "&7燃烧速度: &e1x", "&7燃料效率: &e1x", "&7产物翻倍倍数: &e1x"); - public static final SlimefunItemStack ENHANCED_FURNACE_2 = new SlimefunItemStack("ENHANCED_FURNACE_2", Material.FURNACE, "&7强化熔炉 - &eII", "", "&7燃烧速度: &e2x", "&7燃料效率: &e1x", "&7产物翻倍倍数: &e1x"); - public static final SlimefunItemStack ENHANCED_FURNACE_3 = new SlimefunItemStack("ENHANCED_FURNACE_3", Material.FURNACE, "&7强化熔炉 - &eIII", "", "&7燃烧速度: &e2x", "&7燃料效率: &e2x", "&7产物翻倍倍数: &e1x"); - public static final SlimefunItemStack ENHANCED_FURNACE_4 = new SlimefunItemStack("ENHANCED_FURNACE_4", Material.FURNACE, "&7强化熔炉 - &eIV", "", "&7燃烧速度: &e3x", "&7燃料效率: &e2x", "&7产物翻倍倍数: &e1x"); - public static final SlimefunItemStack ENHANCED_FURNACE_5 = new SlimefunItemStack("ENHANCED_FURNACE_5", Material.FURNACE, "&7强化熔炉 - &eV", "", "&7燃烧速度: &e3x", "&7燃料效率: &e2x", "&7产物翻倍倍数: &e2x"); - public static final SlimefunItemStack ENHANCED_FURNACE_6 = new SlimefunItemStack("ENHANCED_FURNACE_6", Material.FURNACE, "&7强化熔炉 - &eVI", "", "&7燃烧速度: &e3x", "&7燃料效率: &e3x", "&7产物翻倍倍数: &e2x"); - public static final SlimefunItemStack ENHANCED_FURNACE_7 = new SlimefunItemStack("ENHANCED_FURNACE_7", Material.FURNACE, "&7强化熔炉 - &eVII", "", "&7燃烧速度: &e4x", "&7燃料效率: &e3x", "&7产物翻倍倍数: &e2x"); - public static final SlimefunItemStack ENHANCED_FURNACE_8 = new SlimefunItemStack("ENHANCED_FURNACE_8", Material.FURNACE, "&7强化熔炉 - &eVIII", "", "&7燃烧速度: &e4x", "&7燃料效率: &e4x", "&7产物翻倍倍数: &e2x"); - public static final SlimefunItemStack ENHANCED_FURNACE_9 = new SlimefunItemStack("ENHANCED_FURNACE_9", Material.FURNACE, "&7强化熔炉 - &eIX", "", "&7燃烧速度: &e5x", "&7燃料效率: &e4x", "&7产物翻倍倍数: &e2x"); - public static final SlimefunItemStack ENHANCED_FURNACE_10 = new SlimefunItemStack("ENHANCED_FURNACE_10", Material.FURNACE, "&7强化熔炉 - &eX", "", "&7燃烧速度: &e5x", "&7燃料效率: &e5x", "&7产物翻倍倍数: &e2x"); - public static final SlimefunItemStack ENHANCED_FURNACE_11 = new SlimefunItemStack("ENHANCED_FURNACE_11", Material.FURNACE, "&7强化熔炉 - &eXI", "", "&7燃烧速度: &e5x", "&7燃料效率: &e5x", "&7产物翻倍倍数: &e3x"); - public static final SlimefunItemStack REINFORCED_FURNACE = new SlimefunItemStack("REINFORCED_FURNACE", Material.FURNACE, "&7强化合金熔炉", "", "&7燃烧速度: &e10x", "&7燃料效率: &e10x", "&7产物翻倍倍数: &e3x"); - public static final SlimefunItemStack CARBONADO_EDGED_FURNACE = new SlimefunItemStack("CARBONADO_EDGED_FURNACE", Material.FURNACE, "&7黑金刚石镶边熔炉", "", "&7燃烧速度: &e20x", "&7燃料效率: &e10x", "&7产物翻倍倍数: &e3x"); - - public static final SlimefunItemStack BLOCK_PLACER = new SlimefunItemStack("BLOCK_PLACER", Material.DISPENSER, "&a方块放置机", "", "&r所有在这个发射器内的方块", "&r都会被自动放置"); + public static final SlimefunItemStack ENHANCED_FURNACE = new SlimefunItemStack( + "ENHANCED_FURNACE", Material.FURNACE, "&7强化熔炉 - &eI", "", "&7燃烧速度: &e1x", "&7燃料效率: &e1x", "&7产物翻倍倍数: &e1x"); + public static final SlimefunItemStack ENHANCED_FURNACE_2 = new SlimefunItemStack( + "ENHANCED_FURNACE_2", + Material.FURNACE, + "&7强化熔炉 - &eII", + "", + "&7燃烧速度: &e2x", + "&7燃料效率: &e1x", + "&7产物翻倍倍数: &e1x"); + public static final SlimefunItemStack ENHANCED_FURNACE_3 = new SlimefunItemStack( + "ENHANCED_FURNACE_3", + Material.FURNACE, + "&7强化熔炉 - &eIII", + "", + "&7燃烧速度: &e2x", + "&7燃料效率: &e2x", + "&7产物翻倍倍数: &e1x"); + public static final SlimefunItemStack ENHANCED_FURNACE_4 = new SlimefunItemStack( + "ENHANCED_FURNACE_4", + Material.FURNACE, + "&7强化熔炉 - &eIV", + "", + "&7燃烧速度: &e3x", + "&7燃料效率: &e2x", + "&7产物翻倍倍数: &e1x"); + public static final SlimefunItemStack ENHANCED_FURNACE_5 = new SlimefunItemStack( + "ENHANCED_FURNACE_5", + Material.FURNACE, + "&7强化熔炉 - &eV", + "", + "&7燃烧速度: &e3x", + "&7燃料效率: &e2x", + "&7产物翻倍倍数: &e2x"); + public static final SlimefunItemStack ENHANCED_FURNACE_6 = new SlimefunItemStack( + "ENHANCED_FURNACE_6", + Material.FURNACE, + "&7强化熔炉 - &eVI", + "", + "&7燃烧速度: &e3x", + "&7燃料效率: &e3x", + "&7产物翻倍倍数: &e2x"); + public static final SlimefunItemStack ENHANCED_FURNACE_7 = new SlimefunItemStack( + "ENHANCED_FURNACE_7", + Material.FURNACE, + "&7强化熔炉 - &eVII", + "", + "&7燃烧速度: &e4x", + "&7燃料效率: &e3x", + "&7产物翻倍倍数: &e2x"); + public static final SlimefunItemStack ENHANCED_FURNACE_8 = new SlimefunItemStack( + "ENHANCED_FURNACE_8", + Material.FURNACE, + "&7强化熔炉 - &eVIII", + "", + "&7燃烧速度: &e4x", + "&7燃料效率: &e4x", + "&7产物翻倍倍数: &e2x"); + public static final SlimefunItemStack ENHANCED_FURNACE_9 = new SlimefunItemStack( + "ENHANCED_FURNACE_9", + Material.FURNACE, + "&7强化熔炉 - &eIX", + "", + "&7燃烧速度: &e5x", + "&7燃料效率: &e4x", + "&7产物翻倍倍数: &e2x"); + public static final SlimefunItemStack ENHANCED_FURNACE_10 = new SlimefunItemStack( + "ENHANCED_FURNACE_10", + Material.FURNACE, + "&7强化熔炉 - &eX", + "", + "&7燃烧速度: &e5x", + "&7燃料效率: &e5x", + "&7产物翻倍倍数: &e2x"); + public static final SlimefunItemStack ENHANCED_FURNACE_11 = new SlimefunItemStack( + "ENHANCED_FURNACE_11", + Material.FURNACE, + "&7强化熔炉 - &eXI", + "", + "&7燃烧速度: &e5x", + "&7燃料效率: &e5x", + "&7产物翻倍倍数: &e3x"); + public static final SlimefunItemStack REINFORCED_FURNACE = new SlimefunItemStack( + "REINFORCED_FURNACE", Material.FURNACE, "&7强化合金熔炉", "", "&7燃烧速度: &e10x", "&7燃料效率: &e10x", "&7产物翻倍倍数: &e3x"); + public static final SlimefunItemStack CARBONADO_EDGED_FURNACE = new SlimefunItemStack( + "CARBONADO_EDGED_FURNACE", + Material.FURNACE, + "&7黑金刚石镶边熔炉", + "", + "&7燃烧速度: &e20x", + "&7燃料效率: &e10x", + "&7产物翻倍倍数: &e3x"); + + public static final SlimefunItemStack BLOCK_PLACER = + new SlimefunItemStack("BLOCK_PLACER", Material.DISPENSER, "&a方块放置机", "", "&r所有在这个发射器内的方块", "&r都会被自动放置"); /* Soulbound Items */ - public static final SlimefunItemStack SOULBOUND_SWORD = new SlimefunItemStack("SOULBOUND_SWORD", Material.DIAMOND_SWORD, "&c灵魂绑定剑"); - public static final SlimefunItemStack SOULBOUND_BOW = new SlimefunItemStack("SOULBOUND_BOW", Material.BOW, "&c灵魂绑定弓"); - public static final SlimefunItemStack SOULBOUND_PICKAXE = new SlimefunItemStack("SOULBOUND_PICKAXE", Material.DIAMOND_PICKAXE, "&c灵魂绑定镐"); - public static final SlimefunItemStack SOULBOUND_AXE = new SlimefunItemStack("SOULBOUND_AXE", Material.DIAMOND_AXE, "&c灵魂绑定斧"); - public static final SlimefunItemStack SOULBOUND_SHOVEL = new SlimefunItemStack("SOULBOUND_SHOVEL", Material.DIAMOND_SHOVEL, "&c灵魂绑定铲"); - public static final SlimefunItemStack SOULBOUND_HOE = new SlimefunItemStack("SOULBOUND_HOE", Material.DIAMOND_HOE, "&c灵魂绑定锄"); - - public static final SlimefunItemStack SOULBOUND_HELMET = new SlimefunItemStack("SOULBOUND_HELMET", Material.DIAMOND_HELMET, "&c灵魂绑定头盔"); - public static final SlimefunItemStack SOULBOUND_CHESTPLATE = new SlimefunItemStack("SOULBOUND_CHESTPLATE", Material.DIAMOND_CHESTPLATE, "&c灵魂绑定胸甲"); - public static final SlimefunItemStack SOULBOUND_LEGGINGS = new SlimefunItemStack("SOULBOUND_LEGGINGS", Material.DIAMOND_LEGGINGS, "&c灵魂绑定护腿"); - public static final SlimefunItemStack SOULBOUND_BOOTS = new SlimefunItemStack("SOULBOUND_BOOTS", Material.DIAMOND_BOOTS, "&c灵魂绑定靴子"); - public static final SlimefunItemStack SOULBOUND_TRIDENT = new SlimefunItemStack("SOULBOUND_TRIDENT", Material.TRIDENT, "&c灵魂绑定三叉戟"); + public static final SlimefunItemStack SOULBOUND_SWORD = + new SlimefunItemStack("SOULBOUND_SWORD", Material.DIAMOND_SWORD, "&c灵魂绑定剑"); + public static final SlimefunItemStack SOULBOUND_BOW = + new SlimefunItemStack("SOULBOUND_BOW", Material.BOW, "&c灵魂绑定弓"); + public static final SlimefunItemStack SOULBOUND_PICKAXE = + new SlimefunItemStack("SOULBOUND_PICKAXE", Material.DIAMOND_PICKAXE, "&c灵魂绑定镐"); + public static final SlimefunItemStack SOULBOUND_AXE = + new SlimefunItemStack("SOULBOUND_AXE", Material.DIAMOND_AXE, "&c灵魂绑定斧"); + public static final SlimefunItemStack SOULBOUND_SHOVEL = + new SlimefunItemStack("SOULBOUND_SHOVEL", Material.DIAMOND_SHOVEL, "&c灵魂绑定铲"); + public static final SlimefunItemStack SOULBOUND_HOE = + new SlimefunItemStack("SOULBOUND_HOE", Material.DIAMOND_HOE, "&c灵魂绑定锄"); + + public static final SlimefunItemStack SOULBOUND_HELMET = + new SlimefunItemStack("SOULBOUND_HELMET", Material.DIAMOND_HELMET, "&c灵魂绑定头盔"); + public static final SlimefunItemStack SOULBOUND_CHESTPLATE = + new SlimefunItemStack("SOULBOUND_CHESTPLATE", Material.DIAMOND_CHESTPLATE, "&c灵魂绑定胸甲"); + public static final SlimefunItemStack SOULBOUND_LEGGINGS = + new SlimefunItemStack("SOULBOUND_LEGGINGS", Material.DIAMOND_LEGGINGS, "&c灵魂绑定护腿"); + public static final SlimefunItemStack SOULBOUND_BOOTS = + new SlimefunItemStack("SOULBOUND_BOOTS", Material.DIAMOND_BOOTS, "&c灵魂绑定靴子"); + public static final SlimefunItemStack SOULBOUND_TRIDENT = + new SlimefunItemStack("SOULBOUND_TRIDENT", Material.TRIDENT, "&c灵魂绑定三叉戟"); /* Runes */ - public static final SlimefunItemStack BLANK_RUNE = new SlimefunItemStack("BLANK_RUNE", new ColoredFireworkStar(Color.BLACK, "&8空白符文")); - - public static final SlimefunItemStack AIR_RUNE = new SlimefunItemStack("ANCIENT_RUNE_AIR", new ColoredFireworkStar(Color.AQUA, "&7古代符文 &8&l[&b&l气&8&l]")); - public static final SlimefunItemStack WATER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_WATER", new ColoredFireworkStar(Color.BLUE, "&7古代符文 &8&l[&1&l水&8&l]")); - public static final SlimefunItemStack FIRE_RUNE = new SlimefunItemStack("ANCIENT_RUNE_FIRE", new ColoredFireworkStar(Color.RED, "&7古代符文 &8&l[&4&l火&8&l]")); - public static final SlimefunItemStack EARTH_RUNE = new SlimefunItemStack("ANCIENT_RUNE_EARTH", new ColoredFireworkStar(Color.fromRGB(112, 47, 7), "&7古代符文 &8&l[&c&l地&8&l]")); - public static final SlimefunItemStack ENDER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_ENDER", new ColoredFireworkStar(Color.PURPLE, "&7古代符文 &8&l[&5&l末影&8&l]")); - - public static final SlimefunItemStack RAINBOW_RUNE = new SlimefunItemStack("ANCIENT_RUNE_RAINBOW", new ColoredFireworkStar(Color.FUCHSIA, "&7古代符文 &8&l[&d&l虹&8&l]")); - public static final SlimefunItemStack LIGHTNING_RUNE = new SlimefunItemStack("ANCIENT_RUNE_LIGHTNING", new ColoredFireworkStar(Color.fromRGB(255, 255, 95), "&7古代符文 &8&l[&e&l雷&8&l]")); - public static final SlimefunItemStack SOULBOUND_RUNE = new SlimefunItemStack("ANCIENT_RUNE_SOULBOUND", new ColoredFireworkStar(Color.fromRGB(47, 0, 117), "&7古代符文 &8&l[&5&l灵魂绑定&8&l]", "&e先把你要绑定的物品丢到地上", "&e然后把这个符文丢向那个物品", "&5就能灵魂绑定 &e那个物品.", " ", "&e建议你在 &6重要 &e物品上使用.", " ", "&e绑定后的物品死亡后不会掉落.")); - public static final SlimefunItemStack ENCHANTMENT_RUNE = new SlimefunItemStack("ANCIENT_RUNE_ENCHANTMENT", new ColoredFireworkStar(Color.fromRGB(255, 217, 25), "&7古代符文 &8&l[&6&l附魔&8&l]", "&e把符文丢向你已经丢出的", "&e需要被 &6附魔 &e的物品", "&e该物品会获得一个随机的附魔属性.")); - public static final SlimefunItemStack VILLAGER_RUNE = new SlimefunItemStack("ANCIENT_RUNE_VILLAGERS", new ColoredFireworkStar(Color.fromRGB(160, 20, 5), "&7古代符文 &8&l[&4&l村民&8&l]", "&e右键村民清除", "&e它的职业和交易列表.", "&e村民将会在一段时间后", "&e自己寻找新的工作.")); + public static final SlimefunItemStack BLANK_RUNE = + new SlimefunItemStack("BLANK_RUNE", new ColoredFireworkStar(Color.BLACK, "&8空白符文")); + + public static final SlimefunItemStack AIR_RUNE = + new SlimefunItemStack("ANCIENT_RUNE_AIR", new ColoredFireworkStar(Color.AQUA, "&7古代符文 &8&l[&b&l气&8&l]")); + public static final SlimefunItemStack WATER_RUNE = + new SlimefunItemStack("ANCIENT_RUNE_WATER", new ColoredFireworkStar(Color.BLUE, "&7古代符文 &8&l[&1&l水&8&l]")); + public static final SlimefunItemStack FIRE_RUNE = + new SlimefunItemStack("ANCIENT_RUNE_FIRE", new ColoredFireworkStar(Color.RED, "&7古代符文 &8&l[&4&l火&8&l]")); + public static final SlimefunItemStack EARTH_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_EARTH", new ColoredFireworkStar(Color.fromRGB(112, 47, 7), "&7古代符文 &8&l[&c&l地&8&l]")); + public static final SlimefunItemStack ENDER_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_ENDER", new ColoredFireworkStar(Color.PURPLE, "&7古代符文 &8&l[&5&l末影&8&l]")); + + public static final SlimefunItemStack RAINBOW_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_RAINBOW", new ColoredFireworkStar(Color.FUCHSIA, "&7古代符文 &8&l[&d&l虹&8&l]")); + public static final SlimefunItemStack LIGHTNING_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_LIGHTNING", new ColoredFireworkStar(Color.fromRGB(255, 255, 95), "&7古代符文 &8&l[&e&l雷&8&l]")); + public static final SlimefunItemStack SOULBOUND_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_SOULBOUND", + new ColoredFireworkStar( + Color.fromRGB(47, 0, 117), + "&7古代符文 &8&l[&5&l灵魂绑定&8&l]", + "&e先把你要绑定的物品丢到地上", + "&e然后把这个符文丢向那个物品", + "&5就能灵魂绑定 &e那个物品.", + " ", + "&e建议你在 &6重要 &e物品上使用.", + " ", + "&e绑定后的物品死亡后不会掉落.")); + public static final SlimefunItemStack ENCHANTMENT_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_ENCHANTMENT", + new ColoredFireworkStar( + Color.fromRGB(255, 217, 25), + "&7古代符文 &8&l[&6&l附魔&8&l]", + "&e把符文丢向你已经丢出的", + "&e需要被 &6附魔 &e的物品", + "&e该物品会获得一个随机的附魔属性.")); + public static final SlimefunItemStack VILLAGER_RUNE = new SlimefunItemStack( + "ANCIENT_RUNE_VILLAGERS", + new ColoredFireworkStar( + Color.fromRGB(160, 20, 5), + "&7古代符文 &8&l[&4&l村民&8&l]", + "&e右键村民清除", + "&e它的职业和交易列表.", + "&e村民将会在一段时间后", + "&e自己寻找新的工作.")); /* Electricity */ - public static final SlimefunItemStack SOLAR_GENERATOR = new SlimefunItemStack("SOLAR_GENERATOR", Material.DAYLIGHT_DETECTOR, "&b太阳能发电机", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.GENERATOR), LoreBuilder.powerBuffer(0), LoreBuilder.powerPerSecond(4)); - public static final SlimefunItemStack SOLAR_GENERATOR_2 = new SlimefunItemStack("SOLAR_GENERATOR_2", Material.DAYLIGHT_DETECTOR, "&c高级太阳能发电机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), LoreBuilder.powerBuffer(0), LoreBuilder.powerPerSecond(16)); - public static final SlimefunItemStack SOLAR_GENERATOR_3 = new SlimefunItemStack("SOLAR_GENERATOR_3", Material.DAYLIGHT_DETECTOR, "&4黑金刚石太阳能发电机", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), LoreBuilder.powerBuffer(0), LoreBuilder.powerPerSecond(64)); - public static final SlimefunItemStack SOLAR_GENERATOR_4 = new SlimefunItemStack("SOLAR_GENERATOR_4", Material.DAYLIGHT_DETECTOR, "&e充能太阳能发电机", "", "&9可以在夜间工作", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), LoreBuilder.powerBuffer(0), LoreBuilder.powerPerSecond(256), " (日间)", LoreBuilder.powerPerSecond(128), " (夜间)"); - - public static final SlimefunItemStack COAL_GENERATOR = new SlimefunItemStack("COAL_GENERATOR", HeadTexture.GENERATOR, "&c煤发电机", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), LoreBuilder.powerBuffer(64), LoreBuilder.powerPerSecond(16)); - public static final SlimefunItemStack COAL_GENERATOR_2 = new SlimefunItemStack("COAL_GENERATOR_2", HeadTexture.GENERATOR, "&c煤发电机 &7(&eII&7)", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(30)); - - public static final SlimefunItemStack LAVA_GENERATOR = new SlimefunItemStack("LAVA_GENERATOR", HeadTexture.GENERATOR, "&4岩浆发电机", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(20)); - public static final SlimefunItemStack LAVA_GENERATOR_2 = new SlimefunItemStack("LAVA_GENERATOR_2", HeadTexture.GENERATOR, "&4岩浆发电机 &7(&eII&7)", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(40)); - - public static final SlimefunItemStack ELECTRIC_FURNACE = new SlimefunItemStack("ELECTRIC_FURNACE", Material.FURNACE, "&c电炉", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(4)); - public static final SlimefunItemStack ELECTRIC_FURNACE_2 = new SlimefunItemStack("ELECTRIC_FURNACE_2", Material.FURNACE, "&c电炉 &7- &eII", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), "&8\u21E8 &7速度: 2x", LoreBuilder.powerPerSecond(6)); - public static final SlimefunItemStack ELECTRIC_FURNACE_3 = new SlimefunItemStack("ELECTRIC_FURNACE_3", Material.FURNACE, "&c电炉 &7- &eIII", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), "&8\u21E8 &7速度: 4x", LoreBuilder.powerPerSecond(10)); - - public static final SlimefunItemStack ELECTRIC_ORE_GRINDER = new SlimefunItemStack("ELECTRIC_ORE_GRINDER", Material.FURNACE, "&c电力碎矿机", "", "&r矿物粉碎机与磨石的完美结合", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(12)); - public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_2 = new SlimefunItemStack("ELECTRIC_ORE_GRINDER_2", Material.FURNACE, "&c电力碎矿机 &7(&eII&7)", "", "&r矿物粉碎机与磨石的完美结合", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 4x", LoreBuilder.powerPerSecond(30)); - public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_3 = new SlimefunItemStack("ELECTRIC_ORE_GRINDER_3", Material.FURNACE, "&c电力碎矿机 &7(&eIII&7)", "", "&f矿物粉碎机与磨石的完美结合", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(10), LoreBuilder.powerPerSecond(90)); - public static final SlimefunItemStack ELECTRIC_INGOT_PULVERIZER = new SlimefunItemStack("ELECTRIC_INGOT_PULVERIZER", Material.FURNACE, "&c电力打粉机", "", "&r将锭变为粉", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.SMOKER, "&e自动烘干机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(10)); - public static final SlimefunItemStack AUTO_ENCHANTER = new SlimefunItemStack("AUTO_ENCHANTER", Material.ENCHANTING_TABLE, "&5自动附魔机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18)); - public static final SlimefunItemStack AUTO_ENCHANTER_2 = new SlimefunItemStack("AUTO_ENCHANTER_2", Material.ENCHANTING_TABLE, "&5自动附魔机 &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack AUTO_DISENCHANTER = new SlimefunItemStack("AUTO_DISENCHANTER", Material.ENCHANTING_TABLE, "&5自动祛魔机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18)); - public static final SlimefunItemStack AUTO_DISENCHANTER_2 = new SlimefunItemStack("AUTO_DISENCHANTER_2", Material.ENCHANTING_TABLE, "&5自动祛魔机 &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack AUTO_ANVIL = new SlimefunItemStack("AUTO_ANVIL", Material.IRON_BLOCK, "&7自动铁砧", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7可修复百分比: 10%", LoreBuilder.powerPerSecond(24)); - public static final SlimefunItemStack AUTO_ANVIL_2 = new SlimefunItemStack("AUTO_ANVIL_2", Material.IRON_BLOCK, "&7自动铁砧 Mk.II", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7可修复百分比: 25%", LoreBuilder.powerPerSecond(32)); - public static final SlimefunItemStack AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", Material.SMOKER, "&e自动酿造机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12)); - - public static final SlimefunItemStack BOOK_BINDER = new SlimefunItemStack("BOOK_BINDER", Material.BOOKSHELF, "&6附魔书整合机", "", "&f将多个附魔书全部绑定到一本上.", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.powerPerSecond(16)); - - public static final SlimefunItemStack BIO_REACTOR = new SlimefunItemStack("BIO_REACTOR", Material.LIME_TERRACOTTA, "&2生物发电机", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), "&8\u21E8 &e\u26A1 &7128 J 可储存", LoreBuilder.powerPerSecond(8)); - public static final SlimefunItemStack MULTIMETER = new SlimefunItemStack("MULTIMETER", Material.CLOCK, "&e万用表", "", "&r查看机器中储存的能量"); - - public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack("SMALL_CAPACITOR", HeadTexture.CAPACITOR_25, "&a小型储能电容", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7128 J 可储存"); - public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack("MEDIUM_CAPACITOR", HeadTexture.CAPACITOR_25, "&a中型储能电容", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), LoreBuilder.powerBuffer(512)); - public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack("BIG_CAPACITOR", HeadTexture.CAPACITOR_25, "&a大型储能电容", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), LoreBuilder.powerBuffer(1024)); - public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack("LARGE_CAPACITOR", HeadTexture.CAPACITOR_25, "&a巨型储能电容", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), LoreBuilder.powerBuffer(8192)); - public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&a黑金刚石镶边储能电容", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), LoreBuilder.powerBuffer(65536)); - public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&a终极储能电容", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), LoreBuilder.powerBuffer(524288)); + public static final SlimefunItemStack SOLAR_GENERATOR = new SlimefunItemStack( + "SOLAR_GENERATOR", + Material.DAYLIGHT_DETECTOR, + "&b太阳能发电机", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.GENERATOR), + LoreBuilder.powerBuffer(0), + LoreBuilder.powerPerSecond(4)); + public static final SlimefunItemStack SOLAR_GENERATOR_2 = new SlimefunItemStack( + "SOLAR_GENERATOR_2", + Material.DAYLIGHT_DETECTOR, + "&c高级太阳能发电机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), + LoreBuilder.powerBuffer(0), + LoreBuilder.powerPerSecond(16)); + public static final SlimefunItemStack SOLAR_GENERATOR_3 = new SlimefunItemStack( + "SOLAR_GENERATOR_3", + Material.DAYLIGHT_DETECTOR, + "&4黑金刚石太阳能发电机", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), + LoreBuilder.powerBuffer(0), + LoreBuilder.powerPerSecond(64)); + public static final SlimefunItemStack SOLAR_GENERATOR_4 = new SlimefunItemStack( + "SOLAR_GENERATOR_4", + Material.DAYLIGHT_DETECTOR, + "&e充能太阳能发电机", + "", + "&9可以在夜间工作", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), + LoreBuilder.powerBuffer(0), + LoreBuilder.powerPerSecond(256), + " (日间)", + LoreBuilder.powerPerSecond(128), + " (夜间)"); + + public static final SlimefunItemStack COAL_GENERATOR = new SlimefunItemStack( + "COAL_GENERATOR", + HeadTexture.GENERATOR, + "&c煤发电机", + "", + LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), + LoreBuilder.powerBuffer(64), + LoreBuilder.powerPerSecond(16)); + public static final SlimefunItemStack COAL_GENERATOR_2 = new SlimefunItemStack( + "COAL_GENERATOR_2", + HeadTexture.GENERATOR, + "&c煤发电机 &7(&eII&7)", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(30)); + + public static final SlimefunItemStack LAVA_GENERATOR = new SlimefunItemStack( + "LAVA_GENERATOR", + HeadTexture.GENERATOR, + "&4岩浆发电机", + "", + LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), + LoreBuilder.powerBuffer(512), + LoreBuilder.powerPerSecond(20)); + public static final SlimefunItemStack LAVA_GENERATOR_2 = new SlimefunItemStack( + "LAVA_GENERATOR_2", + HeadTexture.GENERATOR, + "&4岩浆发电机 &7(&eII&7)", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), + LoreBuilder.powerBuffer(1024), + LoreBuilder.powerPerSecond(40)); + + public static final SlimefunItemStack ELECTRIC_FURNACE = new SlimefunItemStack( + "ELECTRIC_FURNACE", + Material.FURNACE, + "&c电炉", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(4)); + public static final SlimefunItemStack ELECTRIC_FURNACE_2 = new SlimefunItemStack( + "ELECTRIC_FURNACE_2", + Material.FURNACE, + "&c电炉 &7- &eII", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + "&8\u21E8 &7速度: 2x", + LoreBuilder.powerPerSecond(6)); + public static final SlimefunItemStack ELECTRIC_FURNACE_3 = new SlimefunItemStack( + "ELECTRIC_FURNACE_3", + Material.FURNACE, + "&c电炉 &7- &eIII", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + "&8\u21E8 &7速度: 4x", + LoreBuilder.powerPerSecond(10)); + + public static final SlimefunItemStack ELECTRIC_ORE_GRINDER = new SlimefunItemStack( + "ELECTRIC_ORE_GRINDER", + Material.FURNACE, + "&c电力碎矿机", + "", + "&r矿物粉碎机与磨石的完美结合", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(12)); + public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_2 = new SlimefunItemStack( + "ELECTRIC_ORE_GRINDER_2", + Material.FURNACE, + "&c电力碎矿机 &7(&eII&7)", + "", + "&r矿物粉碎机与磨石的完美结合", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 4x", + LoreBuilder.powerPerSecond(30)); + public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_3 = new SlimefunItemStack( + "ELECTRIC_ORE_GRINDER_3", + Material.FURNACE, + "&c电力碎矿机 &7(&eIII&7)", + "", + "&f矿物粉碎机与磨石的完美结合", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.speed(10), + LoreBuilder.powerPerSecond(90)); + public static final SlimefunItemStack ELECTRIC_INGOT_PULVERIZER = new SlimefunItemStack( + "ELECTRIC_INGOT_PULVERIZER", + Material.FURNACE, + "&c电力打粉机", + "", + "&r将锭变为粉", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(14)); + public static final SlimefunItemStack AUTO_DRIER = new SlimefunItemStack( + "AUTO_DRIER", + Material.SMOKER, + "&e自动烘干机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack AUTO_ENCHANTER = new SlimefunItemStack( + "AUTO_ENCHANTER", + Material.ENCHANTING_TABLE, + "&5自动附魔机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + LoreBuilder.speed(1), + LoreBuilder.powerPerSecond(18)); + public static final SlimefunItemStack AUTO_ENCHANTER_2 = new SlimefunItemStack( + "AUTO_ENCHANTER_2", + Material.ENCHANTING_TABLE, + "&5自动附魔机 &7- &eII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.speed(3), + LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack AUTO_DISENCHANTER = new SlimefunItemStack( + "AUTO_DISENCHANTER", + Material.ENCHANTING_TABLE, + "&5自动祛魔机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + LoreBuilder.speed(1), + LoreBuilder.powerPerSecond(18)); + public static final SlimefunItemStack AUTO_DISENCHANTER_2 = new SlimefunItemStack( + "AUTO_DISENCHANTER_2", + Material.ENCHANTING_TABLE, + "&5自动祛魔机 &7- &eII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.speed(3), + LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack AUTO_ANVIL = new SlimefunItemStack( + "AUTO_ANVIL", + Material.IRON_BLOCK, + "&7自动铁砧", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &7可修复百分比: 10%", + LoreBuilder.powerPerSecond(24)); + public static final SlimefunItemStack AUTO_ANVIL_2 = new SlimefunItemStack( + "AUTO_ANVIL_2", + Material.IRON_BLOCK, + "&7自动铁砧 Mk.II", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7可修复百分比: 25%", + LoreBuilder.powerPerSecond(32)); + public static final SlimefunItemStack AUTO_BREWER = new SlimefunItemStack( + "AUTO_BREWER", + Material.SMOKER, + "&e自动酿造机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + LoreBuilder.speed(1), + LoreBuilder.powerPerSecond(12)); + + public static final SlimefunItemStack BOOK_BINDER = new SlimefunItemStack( + "BOOK_BINDER", + Material.BOOKSHELF, + "&6附魔书整合机", + "", + "&f将多个附魔书全部绑定到一本上.", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + LoreBuilder.powerPerSecond(16)); + + public static final SlimefunItemStack BIO_REACTOR = new SlimefunItemStack( + "BIO_REACTOR", + Material.LIME_TERRACOTTA, + "&2生物发电机", + "", + LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), + "&8\u21E8 &e\u26A1 &7128 J 可储存", + LoreBuilder.powerPerSecond(8)); + public static final SlimefunItemStack MULTIMETER = + new SlimefunItemStack("MULTIMETER", Material.CLOCK, "&e万用表", "", "&r查看机器中储存的能量"); + + public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack( + "SMALL_CAPACITOR", + HeadTexture.CAPACITOR_25, + "&a小型储能电容", + LoreBuilder.range(6), + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), + "&8\u21E8 &e\u26A1 &7128 J 可储存"); + public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack( + "MEDIUM_CAPACITOR", + HeadTexture.CAPACITOR_25, + "&a中型储能电容", + LoreBuilder.range(6), + "", + LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), + LoreBuilder.powerBuffer(512)); + public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack( + "BIG_CAPACITOR", + HeadTexture.CAPACITOR_25, + "&a大型储能电容", + LoreBuilder.range(6), + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), + LoreBuilder.powerBuffer(1024)); + public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack( + "LARGE_CAPACITOR", + HeadTexture.CAPACITOR_25, + "&a巨型储能电容", + LoreBuilder.range(6), + "", + LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), + LoreBuilder.powerBuffer(8192)); + public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack( + "CARBONADO_EDGED_CAPACITOR", + HeadTexture.CAPACITOR_25, + "&a黑金刚石镶边储能电容", + LoreBuilder.range(6), + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), + LoreBuilder.powerBuffer(65536)); + public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack( + "ENERGIZED_CAPACITOR", + HeadTexture.CAPACITOR_25, + "&a终极储能电容", + LoreBuilder.range(6), + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), + LoreBuilder.powerBuffer(524288)); /* Robots */ - public static final SlimefunItemStack PROGRAMMABLE_ANDROID = new SlimefunItemStack("PROGRAMMABLE_ANDROID", HeadTexture.PROGRAMMABLE_ANDROID, "&c可编程式机器人 &7(普通)", "", "&8\u21E8 &7功能: 无", "&8\u21E8 &7燃料效率: 1.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_FARMER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_FARMER", HeadTexture.PROGRAMMABLE_ANDROID_FARMER, "&c可编程式机器人 &7(农夫)", "", "&8\u21E8 &7功能: 耕作", "&8\u21E8 &7燃料效率: 1.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_MINER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_MINER", HeadTexture.PROGRAMMABLE_ANDROID_MINER, "&c可编程式机器人 &7(矿工)", "", "&8\u21E8 &7功能: 挖矿", "&8\u21E8 &7燃料效率: 1.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_WOODCUTTER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_WOODCUTTER", HeadTexture.PROGRAMMABLE_ANDROID_WOODCUTTER, "&c可编程式机器人 &7(樵夫)", "", "&8\u21E8 &7功能: 伐木", "&8\u21E8 &7燃料效率: 1.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_BUTCHER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_BUTCHER", HeadTexture.PROGRAMMABLE_ANDROID_BUTCHER, "&c可编程式机器人 &7(屠夫)", "", "&8\u21E8 &7功能: 屠宰", "&8\u21E8 &7伤害: 4", "&8\u21E8 &7燃料效率: 1.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_FISHERMAN = new SlimefunItemStack("PROGRAMMABLE_ANDROID_FISHERMAN", HeadTexture.PROGRAMMABLE_ANDROID_FISHERMAN, "&c可编程式机器人 &7(渔夫)", "", "&8\u21E8 &7功能: 钓鱼", "&8\u21E8 &7成功几率: 10%", "&8\u21E8 &7燃料效率: 1.0x"); - - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2 = new SlimefunItemStack("PROGRAMMABLE_ANDROID_2", HeadTexture.PROGRAMMABLE_ANDROID, "&c高级可编程式机器人 &7(普通)", "", "&8\u21E8 &7功能: 无", "&8\u21E8 &7燃料效率: 1.5x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2_FISHERMAN = new SlimefunItemStack("PROGRAMMABLE_ANDROID_2_FISHERMAN", HeadTexture.PROGRAMMABLE_ANDROID_FISHERMAN, "&c高级可编程式机器人 &7(渔夫)", "", "&8\u21E8 &7功能: 钓鱼", "&8\u21E8 &7成功几率: 20%", "&8\u21E8 &7燃料效率: 1.5x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2_FARMER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_2_FARMER", HeadTexture.PROGRAMMABLE_ANDROID_FARMER, "&c高级可编程式机器人 &7(农夫)", "", "&8\u21E8 &7功能: 耕作", "&8\u21E8 &7燃料效率: 1.5x", "&8\u21E8 &7可以收割异域花园内的植物"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2_BUTCHER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_2_BUTCHER", HeadTexture.PROGRAMMABLE_ANDROID_BUTCHER, "&c高级可编程式机器人 &7(屠夫)", "", "&8\u21E8 &7功能: 屠宰", "&8\u21E8 &7伤害: 8", "&8\u21E8 &7燃料效率: 1.5x"); - - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_3 = new SlimefunItemStack("PROGRAMMABLE_ANDROID_3", HeadTexture.PROGRAMMABLE_ANDROID, "&e可授权式可编程式机器人 &7(普通)", "", "&8\u21E8 &7功能: 无", "&8\u21E8 &7燃料效率: 3.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_3_FISHERMAN = new SlimefunItemStack("PROGRAMMABLE_ANDROID_3_FISHERMAN", HeadTexture.PROGRAMMABLE_ANDROID_FISHERMAN, "&e可授权式可编程式机器人 &7(渔夫)", "", "&8\u21E8 &7功能: 钓鱼", "&8\u21E8 &7成功几率: 30%", "&8\u21E8 &7燃料效率: 8.0x"); - public static final SlimefunItemStack PROGRAMMABLE_ANDROID_3_BUTCHER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_3_BUTCHER", HeadTexture.PROGRAMMABLE_ANDROID_BUTCHER, "&e可授权式可编程式机器人 &7(屠夫)", "", "&8\u21E8 &7功能: 屠宰", "&8\u21E8 &7伤害: 20", "&8\u21E8 &7燃料效率: 8.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID", + HeadTexture.PROGRAMMABLE_ANDROID, + "&c可编程式机器人 &7(普通)", + "", + "&8\u21E8 &7功能: 无", + "&8\u21E8 &7燃料效率: 1.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_FARMER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_FARMER", + HeadTexture.PROGRAMMABLE_ANDROID_FARMER, + "&c可编程式机器人 &7(农夫)", + "", + "&8\u21E8 &7功能: 耕作", + "&8\u21E8 &7燃料效率: 1.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_MINER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_MINER", + HeadTexture.PROGRAMMABLE_ANDROID_MINER, + "&c可编程式机器人 &7(矿工)", + "", + "&8\u21E8 &7功能: 挖矿", + "&8\u21E8 &7燃料效率: 1.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_WOODCUTTER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_WOODCUTTER", + HeadTexture.PROGRAMMABLE_ANDROID_WOODCUTTER, + "&c可编程式机器人 &7(樵夫)", + "", + "&8\u21E8 &7功能: 伐木", + "&8\u21E8 &7燃料效率: 1.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_BUTCHER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_BUTCHER", + HeadTexture.PROGRAMMABLE_ANDROID_BUTCHER, + "&c可编程式机器人 &7(屠夫)", + "", + "&8\u21E8 &7功能: 屠宰", + "&8\u21E8 &7伤害: 4", + "&8\u21E8 &7燃料效率: 1.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_FISHERMAN = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_FISHERMAN", + HeadTexture.PROGRAMMABLE_ANDROID_FISHERMAN, + "&c可编程式机器人 &7(渔夫)", + "", + "&8\u21E8 &7功能: 钓鱼", + "&8\u21E8 &7成功几率: 10%", + "&8\u21E8 &7燃料效率: 1.0x"); + + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2 = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_2", + HeadTexture.PROGRAMMABLE_ANDROID, + "&c高级可编程式机器人 &7(普通)", + "", + "&8\u21E8 &7功能: 无", + "&8\u21E8 &7燃料效率: 1.5x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2_FISHERMAN = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_2_FISHERMAN", + HeadTexture.PROGRAMMABLE_ANDROID_FISHERMAN, + "&c高级可编程式机器人 &7(渔夫)", + "", + "&8\u21E8 &7功能: 钓鱼", + "&8\u21E8 &7成功几率: 20%", + "&8\u21E8 &7燃料效率: 1.5x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2_FARMER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_2_FARMER", + HeadTexture.PROGRAMMABLE_ANDROID_FARMER, + "&c高级可编程式机器人 &7(农夫)", + "", + "&8\u21E8 &7功能: 耕作", + "&8\u21E8 &7燃料效率: 1.5x", + "&8\u21E8 &7可以收割异域花园内的植物"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_2_BUTCHER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_2_BUTCHER", + HeadTexture.PROGRAMMABLE_ANDROID_BUTCHER, + "&c高级可编程式机器人 &7(屠夫)", + "", + "&8\u21E8 &7功能: 屠宰", + "&8\u21E8 &7伤害: 8", + "&8\u21E8 &7燃料效率: 1.5x"); + + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_3 = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_3", + HeadTexture.PROGRAMMABLE_ANDROID, + "&e可授权式可编程式机器人 &7(普通)", + "", + "&8\u21E8 &7功能: 无", + "&8\u21E8 &7燃料效率: 3.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_3_FISHERMAN = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_3_FISHERMAN", + HeadTexture.PROGRAMMABLE_ANDROID_FISHERMAN, + "&e可授权式可编程式机器人 &7(渔夫)", + "", + "&8\u21E8 &7功能: 钓鱼", + "&8\u21E8 &7成功几率: 30%", + "&8\u21E8 &7燃料效率: 8.0x"); + public static final SlimefunItemStack PROGRAMMABLE_ANDROID_3_BUTCHER = new SlimefunItemStack( + "PROGRAMMABLE_ANDROID_3_BUTCHER", + HeadTexture.PROGRAMMABLE_ANDROID_BUTCHER, + "&e可授权式可编程式机器人 &7(屠夫)", + "", + "&8\u21E8 &7功能: 屠宰", + "&8\u21E8 &7伤害: 20", + "&8\u21E8 &7燃料效率: 8.0x"); /* GPS */ - public static final SlimefunItemStack GPS_TRANSMITTER = new SlimefunItemStack("GPS_TRANSMITTER", HeadTexture.GPS_TRANSMITTER, "&bGPS 发射器", "", LoreBuilder.powerBuffer(16), LoreBuilder.powerPerSecond(2)); - public static final SlimefunItemStack GPS_TRANSMITTER_2 = new SlimefunItemStack("GPS_TRANSMITTER_2", HeadTexture.GPS_TRANSMITTER, "&c高级 GPS 发射器", "", LoreBuilder.powerBuffer(64), LoreBuilder.powerPerSecond(6)); - public static final SlimefunItemStack GPS_TRANSMITTER_3 = new SlimefunItemStack("GPS_TRANSMITTER_3", HeadTexture.GPS_TRANSMITTER, "&4黑金刚石 GPS 发射器", "", LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(22)); - public static final SlimefunItemStack GPS_TRANSMITTER_4 = new SlimefunItemStack("GPS_TRANSMITTER_4", HeadTexture.GPS_TRANSMITTER, "&e充能 GPS 发射器", "", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(92)); - - public static final SlimefunItemStack GPS_MARKER_TOOL = new SlimefunItemStack("GPS_MARKER_TOOL", Material.REDSTONE_TORCH, "&bGPS 设置路径点工具", "", "&r允许你在放置标记工具的位置", "&r设置一个传送点并命名"); - public static final SlimefunItemStack GPS_CONTROL_PANEL = new SlimefunItemStack("GPS_CONTROL_PANEL", HeadTexture.GPS_CONTROL_PANEL, "&bGPS 控制面板", "", "&r允许你追踪你的 GPS 卫星", "&r并且管理已有的路径点"); - public static final SlimefunItemStack GPS_EMERGENCY_TRANSMITTER = new SlimefunItemStack("GPS_EMERGENCY_TRANSMITTER", HeadTexture.GPS_TRANSMITTER, "&cGPS 应急发射器", "", "&r当你死亡的时候", "&r如果应急发射器在你的背包内", "&r将会自动把你的死亡位置设为路径点"); - - public static final SlimefunItemStack ANDROID_INTERFACE_FUEL = new SlimefunItemStack("ANDROID_INTERFACE_FUEL", Material.DISPENSER, "&7机器人交互接口 &c(燃料)", "", "&r当脚本告诉它这样做时", "&r储存在交互接口的物品", "&r将会被放入机器人的燃料槽"); - public static final SlimefunItemStack ANDROID_INTERFACE_ITEMS = new SlimefunItemStack("ANDROID_INTERFACE_ITEMS", Material.DISPENSER, "&7机器人交互接口 &9(物品)", "", "&r当脚本告诉它该这样做时", "&r储存在机器人物品栏的物品", "&r将会被放入交互界面"); - - public static final SlimefunItemStack GPS_GEO_SCANNER = new SlimefunItemStack("GPS_GEO_SCANNER", HeadTexture.GEO_SCANNER, "&bGPS 地形扫描器", "", "&r扫描一个区块中有多少自然资源", "&r例如 &8原油"); - public static final SlimefunItemStack PORTABLE_GEO_SCANNER = new SlimefunItemStack("PORTABLE_GEO_SCANNER", Material.CLOCK, "&b便携式资源扫描器", "", "&r扫描出区块中的自然资源", "", "&e右键&7 扫描"); - public static final SlimefunItemStack GEO_MINER = new SlimefunItemStack("GEO_MINER", HeadTexture.GEO_MINER, "&6自然资源开采机", "", "&e从区块中开采出资源", "&e可以开采出不能被矿镐挖出的资源", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(48), "", "&c&l! &c确保你已经进行了 GEO 地形扫描"); - public static final SlimefunItemStack OIL_PUMP = new SlimefunItemStack("OIL_PUMP", HeadTexture.OIL_PUMP, "&r原油泵", "", "&7泵出原油并把它装进桶里", "", "&c&l! &c请先对所在区块进行地形扫描"); - public static final SlimefunItemStack OIL_BUCKET = new SlimefunItemStack("BUCKET_OF_OIL", HeadTexture.OIL_BUCKET, "&r原油桶"); - public static final SlimefunItemStack FUEL_BUCKET = new SlimefunItemStack("BUCKET_OF_FUEL", HeadTexture.FUEL_BUCKET, "&r燃料桶"); - - public static final SlimefunItemStack REFINERY = new SlimefunItemStack("REFINERY", Material.PISTON, "&c炼油机", "", "&r将原油提炼为燃油"); - public static final SlimefunItemStack COMBUSTION_REACTOR = new SlimefunItemStack("COMBUSTION_REACTOR", HeadTexture.GENERATOR, "&c燃烧反应机", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(24)); - public static final SlimefunItemStack ANDROID_MEMORY_CORE = new SlimefunItemStack("ANDROID_MEMORY_CORE", HeadTexture.ENERGY_REGULATOR, "&b机器人内存核心"); - - public static final SlimefunItemStack GPS_TELEPORTER_PYLON = new SlimefunItemStack("GPS_TELEPORTER_PYLON", Material.PURPLE_STAINED_GLASS, "&5GPS 信号塔", "", "&7传送器组件"); - public static final SlimefunItemStack GPS_TELEPORTATION_MATRIX = new SlimefunItemStack("GPS_TELEPORTATION_MATRIX", Material.IRON_BLOCK, "&bGPS 传送矩阵", "", "&r这是 GPS 传送的主要零件", "&r这个矩阵允许玩家传送至", "&r已设置的路径点"); - public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_SHARED = new SlimefunItemStack("GPS_ACTIVATION_DEVICE_SHARED", Material.STONE_PRESSURE_PLATE, "&rGPS 激活设备 &3(公共)", "", "&r把它放在传送矩阵上", "&r并且踩下这个踏板以选择", "&r要传送的路径点"); - public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_PERSONAL = new SlimefunItemStack("GPS_ACTIVATION_DEVICE_PERSONAL", Material.STONE_PRESSURE_PLATE, "&rGPS 激活设备 &a(私人)", "", "&r把它放在传送矩阵上", "&r并且踩下这个踏板以选择", "&r要传送的路径点", "", "&r这种激活装置仅允许", "&r放置它的人使用"); - public static final SlimefunItemStack PORTABLE_TELEPORTER = new SlimefunItemStack("PORTABLE_TELEPORTER", Material.COMPASS, "&b便携式传送器", "", "&f可以让你随时随地传送到", "&f要传送的传送点", "", LoreBuilder.powerCharged(0, 50), "", "&e右键&7 使用"); - - public static final SlimefunItemStack ELEVATOR_PLATE = new SlimefunItemStack("ELEVATOR_PLATE", Material.STONE_PRESSURE_PLATE, "&b电梯板", "", "&r在每一层放置电梯板", "&r你就能够在每一层之间传送.", "", "&e右键电梯板&7 以为此层命名"); - - public static final SlimefunItemStack INFUSED_HOPPER = new SlimefunItemStack("INFUSED_HOPPER", Material.HOPPER, "&5吸入漏斗", "", "&r自动吸入在漏斗附近", "&r7x7x7 范围内的所有物品"); - - public static final SlimefunItemStack PLASTIC_SHEET = new SlimefunItemStack("PLASTIC_SHEET", Material.PAPER, "&r塑料纸"); - - public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER = new SlimefunItemStack("HEATED_PRESSURE_CHAMBER", Material.LIGHT_GRAY_STAINED_GLASS, "&c加热压力舱", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(10)); - public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER_2 = new SlimefunItemStack("HEATED_PRESSURE_CHAMBER_2", Material.LIGHT_GRAY_STAINED_GLASS, "&c加热压力舱 &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 5x", LoreBuilder.powerPerSecond(44)); - - public static final SlimefunItemStack ELECTRIC_SMELTERY = new SlimefunItemStack("ELECTRIC_SMELTERY", Material.FURNACE, "&c电力冶炼炉", "", "&4仅支持合金, 不能将粉冶炼成锭", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(20)); - public static final SlimefunItemStack ELECTRIC_SMELTERY_2 = new SlimefunItemStack("ELECTRIC_SMELTERY_2", Material.FURNACE, "&c电力冶炼炉 &7- &eII", "", "&4仅支持合金, 不能将粉冶炼成锭", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 3x", LoreBuilder.powerPerSecond(40)); - - public static final SlimefunItemStack ELECTRIC_PRESS = new SlimefunItemStack("ELECTRIC_PRESS", HeadTexture.ELECTRIC_PRESS, "&e压缩机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(16)); - public static final SlimefunItemStack ELECTRIC_PRESS_2 = new SlimefunItemStack("ELECTRIC_PRESS_2", HeadTexture.ELECTRIC_PRESS, "&e压缩机 &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 3x", LoreBuilder.powerPerSecond(40)); - - public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE", Material.RED_TERRACOTTA, "&c电动坩埚", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(48)); - public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_2 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_2", Material.RED_TERRACOTTA, "&c电动坩埚 &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 2x", "&8\u21E8 &e\u26A1 &780 J/s"); - public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_3 = new SlimefunItemStack("ELECTRIFIED_CRUCIBLE_3", Material.RED_TERRACOTTA, "&c电动坩埚 &7- &eIII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 4x", "&8\u21E8 &e\u26A1 &7120 J/s"); - - public static final SlimefunItemStack CARBON_PRESS = new SlimefunItemStack("CARBON_PRESS", Material.BLACK_STAINED_GLASS, "&c碳压机", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(20)); - public static final SlimefunItemStack CARBON_PRESS_2 = new SlimefunItemStack("CARBON_PRESS_2", Material.BLACK_STAINED_GLASS, "&c碳压机 &7- &eII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 3x", "&8\u21E8 &e\u26A1 &750 J/s"); - public static final SlimefunItemStack CARBON_PRESS_3 = new SlimefunItemStack("CARBON_PRESS_3", Material.BLACK_STAINED_GLASS, "&c碳压机 &7- &eIII", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 15x", "&8\u21E8 &e\u26A1 &7180 J/s"); - - public static final SlimefunItemStack BLISTERING_INGOT = new SlimefunItemStack("BLISTERING_INGOT", Material.GOLD_INGOT, "&6起泡锭 &7(33%)", "", LoreBuilder.radioactive(Radioactivity.HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack BLISTERING_INGOT_2 = new SlimefunItemStack("BLISTERING_INGOT_2", Material.GOLD_INGOT, "&6起泡锭 &7(66%)", "", LoreBuilder.radioactive(Radioactivity.HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack("BLISTERING_INGOT_3", Material.GOLD_INGOT, "&6起泡锭", "", LoreBuilder.radioactive(Radioactivity.HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - - public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6能源调节器", "", "&r能源网络的核心部分"); - public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.ENERGY_CONNECTOR, "&c能源连接器", LoreBuilder.range(6), "", "&f用于连接机器和发电机", "&f可以连接到附近的能源网络"); - public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3这鱼多少钱?", "", "&e右键 &r任意方块以查看它的方块数据", "&e左键 &r破坏方块", "&eShift + 左键 &r任意方块以清除它的方块数据", "&eShift + 右键 &r放置一个占位符方块"); - - public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&e下界冰", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack ENRICHED_NETHER_ICE = new SlimefunItemStack("ENRICHED_NETHER_ICE", HeadTexture.ENRICHED_NETHER_ICE, "&e浓缩下界冰", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED); - public static final SlimefunItemStack NETHER_ICE_COOLANT_CELL = new SlimefunItemStack("NETHER_ICE_COOLANT_CELL", HeadTexture.NETHER_ICE_COOLANT_CELL, "&6下界冰冷却剂"); + public static final SlimefunItemStack GPS_TRANSMITTER = new SlimefunItemStack( + "GPS_TRANSMITTER", + HeadTexture.GPS_TRANSMITTER, + "&bGPS 发射器", + "", + LoreBuilder.powerBuffer(16), + LoreBuilder.powerPerSecond(2)); + public static final SlimefunItemStack GPS_TRANSMITTER_2 = new SlimefunItemStack( + "GPS_TRANSMITTER_2", + HeadTexture.GPS_TRANSMITTER, + "&c高级 GPS 发射器", + "", + LoreBuilder.powerBuffer(64), + LoreBuilder.powerPerSecond(6)); + public static final SlimefunItemStack GPS_TRANSMITTER_3 = new SlimefunItemStack( + "GPS_TRANSMITTER_3", + HeadTexture.GPS_TRANSMITTER, + "&4黑金刚石 GPS 发射器", + "", + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(22)); + public static final SlimefunItemStack GPS_TRANSMITTER_4 = new SlimefunItemStack( + "GPS_TRANSMITTER_4", + HeadTexture.GPS_TRANSMITTER, + "&e充能 GPS 发射器", + "", + LoreBuilder.powerBuffer(1024), + LoreBuilder.powerPerSecond(92)); + + public static final SlimefunItemStack GPS_MARKER_TOOL = new SlimefunItemStack( + "GPS_MARKER_TOOL", Material.REDSTONE_TORCH, "&bGPS 设置路径点工具", "", "&r允许你在放置标记工具的位置", "&r设置一个传送点并命名"); + public static final SlimefunItemStack GPS_CONTROL_PANEL = new SlimefunItemStack( + "GPS_CONTROL_PANEL", HeadTexture.GPS_CONTROL_PANEL, "&bGPS 控制面板", "", "&r允许你追踪你的 GPS 卫星", "&r并且管理已有的路径点"); + public static final SlimefunItemStack GPS_EMERGENCY_TRANSMITTER = new SlimefunItemStack( + "GPS_EMERGENCY_TRANSMITTER", + HeadTexture.GPS_TRANSMITTER, + "&cGPS 应急发射器", + "", + "&r当你死亡的时候", + "&r如果应急发射器在你的背包内", + "&r将会自动把你的死亡位置设为路径点"); + + public static final SlimefunItemStack ANDROID_INTERFACE_FUEL = new SlimefunItemStack( + "ANDROID_INTERFACE_FUEL", + Material.DISPENSER, + "&7机器人交互接口 &c(燃料)", + "", + "&r当脚本告诉它这样做时", + "&r储存在交互接口的物品", + "&r将会被放入机器人的燃料槽"); + public static final SlimefunItemStack ANDROID_INTERFACE_ITEMS = new SlimefunItemStack( + "ANDROID_INTERFACE_ITEMS", + Material.DISPENSER, + "&7机器人交互接口 &9(物品)", + "", + "&r当脚本告诉它该这样做时", + "&r储存在机器人物品栏的物品", + "&r将会被放入交互界面"); + + public static final SlimefunItemStack GPS_GEO_SCANNER = new SlimefunItemStack( + "GPS_GEO_SCANNER", HeadTexture.GEO_SCANNER, "&bGPS 地形扫描器", "", "&r扫描一个区块中有多少自然资源", "&r例如 &8原油"); + public static final SlimefunItemStack PORTABLE_GEO_SCANNER = new SlimefunItemStack( + "PORTABLE_GEO_SCANNER", Material.CLOCK, "&b便携式资源扫描器", "", "&r扫描出区块中的自然资源", "", "&e右键&7 扫描"); + public static final SlimefunItemStack GEO_MINER = new SlimefunItemStack( + "GEO_MINER", + HeadTexture.GEO_MINER, + "&6自然资源开采机", + "", + "&e从区块中开采出资源", + "&e可以开采出不能被矿镐挖出的资源", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(48), + "", + "&c&l! &c确保你已经进行了 GEO 地形扫描"); + public static final SlimefunItemStack OIL_PUMP = new SlimefunItemStack( + "OIL_PUMP", HeadTexture.OIL_PUMP, "&r原油泵", "", "&7泵出原油并把它装进桶里", "", "&c&l! &c请先对所在区块进行地形扫描"); + public static final SlimefunItemStack OIL_BUCKET = + new SlimefunItemStack("BUCKET_OF_OIL", HeadTexture.OIL_BUCKET, "&r原油桶"); + public static final SlimefunItemStack FUEL_BUCKET = + new SlimefunItemStack("BUCKET_OF_FUEL", HeadTexture.FUEL_BUCKET, "&r燃料桶"); + + public static final SlimefunItemStack REFINERY = + new SlimefunItemStack("REFINERY", Material.PISTON, "&c炼油机", "", "&r将原油提炼为燃油"); + public static final SlimefunItemStack COMBUSTION_REACTOR = new SlimefunItemStack( + "COMBUSTION_REACTOR", + HeadTexture.GENERATOR, + "&c燃烧反应机", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.GENERATOR), + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(24)); + public static final SlimefunItemStack ANDROID_MEMORY_CORE = + new SlimefunItemStack("ANDROID_MEMORY_CORE", HeadTexture.ENERGY_REGULATOR, "&b机器人内存核心"); + + public static final SlimefunItemStack GPS_TELEPORTER_PYLON = + new SlimefunItemStack("GPS_TELEPORTER_PYLON", Material.PURPLE_STAINED_GLASS, "&5GPS 信号塔", "", "&7传送器组件"); + public static final SlimefunItemStack GPS_TELEPORTATION_MATRIX = new SlimefunItemStack( + "GPS_TELEPORTATION_MATRIX", + Material.IRON_BLOCK, + "&bGPS 传送矩阵", + "", + "&r这是 GPS 传送的主要零件", + "&r这个矩阵允许玩家传送至", + "&r已设置的路径点"); + public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_SHARED = new SlimefunItemStack( + "GPS_ACTIVATION_DEVICE_SHARED", + Material.STONE_PRESSURE_PLATE, + "&rGPS 激活设备 &3(公共)", + "", + "&r把它放在传送矩阵上", + "&r并且踩下这个踏板以选择", + "&r要传送的路径点"); + public static final SlimefunItemStack GPS_ACTIVATION_DEVICE_PERSONAL = new SlimefunItemStack( + "GPS_ACTIVATION_DEVICE_PERSONAL", + Material.STONE_PRESSURE_PLATE, + "&rGPS 激活设备 &a(私人)", + "", + "&r把它放在传送矩阵上", + "&r并且踩下这个踏板以选择", + "&r要传送的路径点", + "", + "&r这种激活装置仅允许", + "&r放置它的人使用"); + public static final SlimefunItemStack PORTABLE_TELEPORTER = new SlimefunItemStack( + "PORTABLE_TELEPORTER", + Material.COMPASS, + "&b便携式传送器", + "", + "&f可以让你随时随地传送到", + "&f要传送的传送点", + "", + LoreBuilder.powerCharged(0, 50), + "", + "&e右键&7 使用"); + + public static final SlimefunItemStack ELEVATOR_PLATE = new SlimefunItemStack( + "ELEVATOR_PLATE", + Material.STONE_PRESSURE_PLATE, + "&b电梯板", + "", + "&r在每一层放置电梯板", + "&r你就能够在每一层之间传送.", + "", + "&e右键电梯板&7 以为此层命名"); + + public static final SlimefunItemStack INFUSED_HOPPER = + new SlimefunItemStack("INFUSED_HOPPER", Material.HOPPER, "&5吸入漏斗", "", "&r自动吸入在漏斗附近", "&r7x7x7 范围内的所有物品"); + + public static final SlimefunItemStack PLASTIC_SHEET = + new SlimefunItemStack("PLASTIC_SHEET", Material.PAPER, "&r塑料纸"); + + public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER = new SlimefunItemStack( + "HEATED_PRESSURE_CHAMBER", + Material.LIGHT_GRAY_STAINED_GLASS, + "&c加热压力舱", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack HEATED_PRESSURE_CHAMBER_2 = new SlimefunItemStack( + "HEATED_PRESSURE_CHAMBER_2", + Material.LIGHT_GRAY_STAINED_GLASS, + "&c加热压力舱 &7- &eII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 5x", + LoreBuilder.powerPerSecond(44)); + + public static final SlimefunItemStack ELECTRIC_SMELTERY = new SlimefunItemStack( + "ELECTRIC_SMELTERY", + Material.FURNACE, + "&c电力冶炼炉", + "", + "&4仅支持合金, 不能将粉冶炼成锭", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(20)); + public static final SlimefunItemStack ELECTRIC_SMELTERY_2 = new SlimefunItemStack( + "ELECTRIC_SMELTERY_2", + Material.FURNACE, + "&c电力冶炼炉 &7- &eII", + "", + "&4仅支持合金, 不能将粉冶炼成锭", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 3x", + LoreBuilder.powerPerSecond(40)); + + public static final SlimefunItemStack ELECTRIC_PRESS = new SlimefunItemStack( + "ELECTRIC_PRESS", + HeadTexture.ELECTRIC_PRESS, + "&e压缩机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(16)); + public static final SlimefunItemStack ELECTRIC_PRESS_2 = new SlimefunItemStack( + "ELECTRIC_PRESS_2", + HeadTexture.ELECTRIC_PRESS, + "&e压缩机 &7- &eII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 3x", + LoreBuilder.powerPerSecond(40)); + + public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE = new SlimefunItemStack( + "ELECTRIFIED_CRUCIBLE", + Material.RED_TERRACOTTA, + "&c电动坩埚", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(48)); + public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_2 = new SlimefunItemStack( + "ELECTRIFIED_CRUCIBLE_2", + Material.RED_TERRACOTTA, + "&c电动坩埚 &7- &eII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 2x", + "&8\u21E8 &e\u26A1 &780 J/s"); + public static final SlimefunItemStack ELECTRIFIED_CRUCIBLE_3 = new SlimefunItemStack( + "ELECTRIFIED_CRUCIBLE_3", + Material.RED_TERRACOTTA, + "&c电动坩埚 &7- &eIII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 4x", + "&8\u21E8 &e\u26A1 &7120 J/s"); + + public static final SlimefunItemStack CARBON_PRESS = new SlimefunItemStack( + "CARBON_PRESS", + Material.BLACK_STAINED_GLASS, + "&c碳压机", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(20)); + public static final SlimefunItemStack CARBON_PRESS_2 = new SlimefunItemStack( + "CARBON_PRESS_2", + Material.BLACK_STAINED_GLASS, + "&c碳压机 &7- &eII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 3x", + "&8\u21E8 &e\u26A1 &750 J/s"); + public static final SlimefunItemStack CARBON_PRESS_3 = new SlimefunItemStack( + "CARBON_PRESS_3", + Material.BLACK_STAINED_GLASS, + "&c碳压机 &7- &eIII", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 15x", + "&8\u21E8 &e\u26A1 &7180 J/s"); + + public static final SlimefunItemStack BLISTERING_INGOT = new SlimefunItemStack( + "BLISTERING_INGOT", + Material.GOLD_INGOT, + "&6起泡锭 &7(33%)", + "", + LoreBuilder.radioactive(Radioactivity.HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack BLISTERING_INGOT_2 = new SlimefunItemStack( + "BLISTERING_INGOT_2", + Material.GOLD_INGOT, + "&6起泡锭 &7(66%)", + "", + LoreBuilder.radioactive(Radioactivity.HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack( + "BLISTERING_INGOT_3", + Material.GOLD_INGOT, + "&6起泡锭", + "", + LoreBuilder.radioactive(Radioactivity.HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + + public static final SlimefunItemStack ENERGY_REGULATOR = + new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6能源调节器", "", "&r能源网络的核心部分"); + public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack( + "ENERGY_CONNECTOR", + HeadTexture.ENERGY_CONNECTOR, + "&c能源连接器", + LoreBuilder.range(6), + "", + "&f用于连接机器和发电机", + "&f可以连接到附近的能源网络"); + public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack( + "DEBUG_FISH", + Material.SALMON, + "&3这鱼多少钱?", + "", + "&e右键 &r任意方块以查看它的方块数据", + "&e左键 &r破坏方块", + "&eShift + 左键 &r任意方块以清除它的方块数据", + "&eShift + 右键 &r放置一个占位符方块"); + + public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack( + "NETHER_ICE", + HeadTexture.NETHER_ICE, + "&e下界冰", + "", + LoreBuilder.radioactive(Radioactivity.MODERATE), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack ENRICHED_NETHER_ICE = new SlimefunItemStack( + "ENRICHED_NETHER_ICE", + HeadTexture.ENRICHED_NETHER_ICE, + "&e浓缩下界冰", + "", + LoreBuilder.radioactive(Radioactivity.VERY_HIGH), + LoreBuilder.HAZMAT_SUIT_REQUIRED); + public static final SlimefunItemStack NETHER_ICE_COOLANT_CELL = + new SlimefunItemStack("NETHER_ICE_COOLANT_CELL", HeadTexture.NETHER_ICE_COOLANT_CELL, "&6下界冰冷却剂"); // Cargo - public static final SlimefunItemStack CARGO_MANAGER = new SlimefunItemStack("CARGO_MANAGER", HeadTexture.CARGO_MANAGER, "&6货运管理器", "", "&r物品传输网络的核心组件"); - public static final SlimefunItemStack CARGO_CONNECTOR_NODE = new SlimefunItemStack("CARGO_NODE", HeadTexture.CARGO_CONNECTOR_NODE, "&7货运节点 &c(连接器)", "", "&r货运连接管道"); - public static final SlimefunItemStack CARGO_INPUT_NODE = new SlimefunItemStack("CARGO_NODE_INPUT", HeadTexture.CARGO_INPUT_NODE, "&7货运节点 &c(输入)", "", "&r货运输入管道"); - public static final SlimefunItemStack CARGO_OUTPUT_NODE = new SlimefunItemStack("CARGO_NODE_OUTPUT", HeadTexture.CARGO_OUTPUT_NODE, "&7货运节点 &c(输出)", "", "&r货运输出管道"); - public static final SlimefunItemStack CARGO_OUTPUT_NODE_2 = new SlimefunItemStack("CARGO_NODE_OUTPUT_ADVANCED", HeadTexture.CARGO_OUTPUT_NODE, "&6高级货运节点 &c(输出)", "", "&r货运输出管道"); + public static final SlimefunItemStack CARGO_MANAGER = + new SlimefunItemStack("CARGO_MANAGER", HeadTexture.CARGO_MANAGER, "&6货运管理器", "", "&r物品传输网络的核心组件"); + public static final SlimefunItemStack CARGO_CONNECTOR_NODE = + new SlimefunItemStack("CARGO_NODE", HeadTexture.CARGO_CONNECTOR_NODE, "&7货运节点 &c(连接器)", "", "&r货运连接管道"); + public static final SlimefunItemStack CARGO_INPUT_NODE = + new SlimefunItemStack("CARGO_NODE_INPUT", HeadTexture.CARGO_INPUT_NODE, "&7货运节点 &c(输入)", "", "&r货运输入管道"); + public static final SlimefunItemStack CARGO_OUTPUT_NODE = + new SlimefunItemStack("CARGO_NODE_OUTPUT", HeadTexture.CARGO_OUTPUT_NODE, "&7货运节点 &c(输出)", "", "&r货运输出管道"); + public static final SlimefunItemStack CARGO_OUTPUT_NODE_2 = new SlimefunItemStack( + "CARGO_NODE_OUTPUT_ADVANCED", HeadTexture.CARGO_OUTPUT_NODE, "&6高级货运节点 &c(输出)", "", "&r货运输出管道"); // Animal farm - public static final SlimefunItemStack AUTO_BREEDER = new SlimefunItemStack("AUTO_BREEDER", Material.HAY_BLOCK, "&e自动喂食机", "", "&r需要 &a有机食物", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.powerBuffer(1024), "&8\u21E8 &e\u26A1 &760 J/个动物"); - public static final SlimefunItemStack PRODUCE_COLLECTOR = new SlimefunItemStack("PRODUCE_COLLECTOR", Material.HAY_BLOCK, "&b全自动收集机", "", "&f此机器可以自动收取", "&f附近动物生产的动物产品.", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(32)); - - public static final SlimefunItemStack ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD", HeadTexture.FILLED_CAN, "&a有机食物", "&7内含 &9???"); - public static final SlimefunItemStack WHEAT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_WHEAT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9小麦"); - public static final SlimefunItemStack CARROT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_CARROT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9胡萝卜"); - public static final SlimefunItemStack POTATO_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_POTATO", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9土豆"); - public static final SlimefunItemStack SEEDS_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SEEDS", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9小麦种子"); - public static final SlimefunItemStack BEETROOT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_BEETROOT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9甜菜"); - public static final SlimefunItemStack MELON_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_MELON", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9西瓜"); - public static final SlimefunItemStack APPLE_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_APPLE", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9苹果"); - public static final SlimefunItemStack SWEET_BERRIES_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SWEET_BERRIES", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9浆果"); - public static final SlimefunItemStack KELP_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_KELP", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9干海带"); - public static final SlimefunItemStack COCOA_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_COCOA", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9可可豆"); - public static final SlimefunItemStack SEAGRASS_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SEAGRASS", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含: &9海草"); - - public static final SlimefunItemStack FERTILIZER = new SlimefunItemStack("FERTILIZER", HeadTexture.FILLED_CAN, "&a有机肥料", "&7内含 &9???"); - public static final SlimefunItemStack WHEAT_FERTILIZER = new SlimefunItemStack("FERTILIZER_WHEAT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9小麦"); - public static final SlimefunItemStack CARROT_FERTILIZER = new SlimefunItemStack("FERTILIZER_CARROT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9胡萝卜"); - public static final SlimefunItemStack POTATO_FERTILIZER = new SlimefunItemStack("FERTILIZER_POTATO", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9土豆"); - public static final SlimefunItemStack SEEDS_FERTILIZER = new SlimefunItemStack("FERTILIZER_SEEDS", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9小麦种子"); - public static final SlimefunItemStack BEETROOT_FERTILIZER = new SlimefunItemStack("FERTILIZER_BEETROOT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9甜菜"); - public static final SlimefunItemStack MELON_FERTILIZER = new SlimefunItemStack("FERTILIZER_MELON", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9西瓜"); - public static final SlimefunItemStack APPLE_FERTILIZER = new SlimefunItemStack("FERTILIZER_APPLE", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9苹果"); - public static final SlimefunItemStack SWEET_BERRIES_FERTILIZER = new SlimefunItemStack("FERTILIZER_SWEET_BERRIES", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9浆果"); - public static final SlimefunItemStack KELP_FERTILIZER = new SlimefunItemStack("FERTILIZER_KELP", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9干海带"); - public static final SlimefunItemStack COCOA_FERTILIZER = new SlimefunItemStack("FERTILIZER_COCOA", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9可可豆"); - public static final SlimefunItemStack SEAGRASS_FERTILIZER = new SlimefunItemStack("FERTILIZER_SEAGRASS", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含: &9海草"); - - public static final SlimefunItemStack ANIMAL_GROWTH_ACCELERATOR = new SlimefunItemStack("ANIMAL_GROWTH_ACCELERATOR", Material.HAY_BLOCK, "&b动物生长加速器", "", "&r需要 &a有机食物", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(28)); - public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR = new SlimefunItemStack("CROP_GROWTH_ACCELERATOR", Material.LIME_TERRACOTTA, "&a作物生长加速器", "", "&r需要 &a有机肥料", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7半径: 7x7", "&8\u21E8 &7速度: &a3/次", LoreBuilder.powerBuffer(1024), "&8\u21E8 &e\u26A1 &750 J/s"); - public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR_2 = new SlimefunItemStack("CROP_GROWTH_ACCELERATOR_2", Material.LIME_TERRACOTTA, "&a作物生长加速器 &7(&eII&7)", "", "&r需要 &a有机肥料", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7半径: 9x9", "&8\u21E8 &7速度: &a4/次", LoreBuilder.powerBuffer(1024), "&8\u21E8 &e\u26A1 &760 J/s"); - public static final SlimefunItemStack TREE_GROWTH_ACCELERATOR = new SlimefunItemStack("TREE_GROWTH_ACCELERATOR", Material.BROWN_TERRACOTTA, "&a树木生长加速器", "", "&r需要 &a有机肥料", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7半径: 9x9", "&8\u21E8 &7速度: &a4/次", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(48)); - - public static final SlimefunItemStack FOOD_FABRICATOR = new SlimefunItemStack("FOOD_FABRICATOR", Material.GREEN_STAINED_GLASS, "&c食品加工机", "", "&r可制造 &a有机食物", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack FOOD_FABRICATOR_2 = new SlimefunItemStack("FOOD_FABRICATOR_2", Material.GREEN_STAINED_GLASS, "&c食品加工机 &7(&eII&7)", "", "&r可制造 &a有机食物", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 6x", LoreBuilder.powerBuffer(512), LoreBuilder.powerPerSecond(48)); - - public static final SlimefunItemStack FOOD_COMPOSTER = new SlimefunItemStack("FOOD_COMPOSTER", Material.GREEN_TERRACOTTA, "&c食品堆肥器", "", "&r可制造 &a有机肥料", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(16)); - public static final SlimefunItemStack FOOD_COMPOSTER_2 = new SlimefunItemStack("FOOD_COMPOSTER_2", Material.GREEN_TERRACOTTA, "&c食品堆肥器 &7(&eII&7)", "", "&r可制造 &a有机肥料", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 10x", LoreBuilder.powerBuffer(512), "&8\u21E8 &e\u26A1 &752 J/s"); - - public static final SlimefunItemStack EXP_COLLECTOR = new SlimefunItemStack("XP_COLLECTOR", HeadTexture.EXP_COLLECTOR, "&a经验收集器", "", "&r收集附近的经验并储存它们", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(20)); - public static final SlimefunItemStack REACTOR_COOLANT_CELL = new SlimefunItemStack("REACTOR_COLLANT_CELL", HeadTexture.COOLANT_CELL, "&b反应堆冷却剂"); - - public static final SlimefunItemStack NUCLEAR_REACTOR = new SlimefunItemStack("NUCLEAR_REACTOR", HeadTexture.NUCLEAR_REACTOR, "&2核反应堆", "", "&r需要冷却剂!", "&8\u21E8 &b必须被水包围", "&8\u21E8 &b必须使用反应堆冷却剂工作", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), "&8\u21E8 &e\u26A1 &716384 J 可储存", "&8\u21E8 &e\u26A1 &7500 J/s"); - public static final SlimefunItemStack NETHER_STAR_REACTOR = new SlimefunItemStack("NETHERSTAR_REACTOR", HeadTexture.NETHER_STAR_REACTOR, "&r下界之星反应堆", "", "&r需要下界之星", "&8\u21E8 &b必须被水包围", "&8\u21E8 &b必须使用下界冰冷却剂工作", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), "&8\u21E8 &e\u26A1 &732768 J 可储存", "&8\u21E8 &e\u26A1 &71024 J/s", "&8\u21E8 &4会导致附近的生物获得凋零效果"); - public static final SlimefunItemStack REACTOR_ACCESS_PORT = new SlimefunItemStack("REACTOR_ACCESS_PORT", Material.CYAN_TERRACOTTA, "&2反应堆访问接口", "", "&r允许你通过货运节点来访问反应堆", "&r也可以用于储存", "", "&8\u21E8 &c必须 &e放置在反应堆上方的第三格处"); - - public static final SlimefunItemStack FREEZER = new SlimefunItemStack("FREEZER", Material.LIGHT_BLUE_STAINED_GLASS, "&b冰箱", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(18)); - public static final SlimefunItemStack FREEZER_2 = new SlimefunItemStack("FREEZER_2", Material.LIGHT_BLUE_STAINED_GLASS, "&b冰箱 &7(&eII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 2x", LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(30)); - public static final SlimefunItemStack FREEZER_3 = new SlimefunItemStack("FREEZER_3", Material.LIGHT_GRAY_STAINED_GLASS, "&b冰箱 &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(3), LoreBuilder.powerBuffer(256), LoreBuilder.powerPerSecond(42)); - - public static final SlimefunItemStack ELECTRIC_GOLD_PAN = new SlimefunItemStack("ELECTRIC_GOLD_PAN", Material.BROWN_TERRACOTTA, "&6电动淘金机", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(2)); - public static final SlimefunItemStack ELECTRIC_GOLD_PAN_2 = new SlimefunItemStack("ELECTRIC_GOLD_PAN_2", Material.BROWN_TERRACOTTA, "&6电动淘金机 &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 3x", LoreBuilder.powerPerSecond(4)); - public static final SlimefunItemStack ELECTRIC_GOLD_PAN_3 = new SlimefunItemStack("ELECTRIC_GOLD_PAN_3", Material.BROWN_TERRACOTTA, "&6电动淘金机 &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 10x", LoreBuilder.powerPerSecond(14)); - - public static final SlimefunItemStack ELECTRIC_DUST_WASHER = new SlimefunItemStack("ELECTRIC_DUST_WASHER", Material.BLUE_STAINED_GLASS, "&3电动洗矿机", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(6)); - public static final SlimefunItemStack ELECTRIC_DUST_WASHER_2 = new SlimefunItemStack("ELECTRIC_DUST_WASHER_2", Material.BLUE_STAINED_GLASS, "&3电动洗矿机 &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 2x", LoreBuilder.powerPerSecond(10)); - public static final SlimefunItemStack ELECTRIC_DUST_WASHER_3 = new SlimefunItemStack("ELECTRIC_DUST_WASHER_3", Material.BLUE_STAINED_GLASS, "&3电动洗矿机 &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 10x", LoreBuilder.powerPerSecond(30)); - - public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY", Material.RED_TERRACOTTA, "&c电动铸锭机", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 1x", LoreBuilder.powerPerSecond(8)); - public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_2 = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY_2", Material.RED_TERRACOTTA, "&c电动铸锭机 &7(&eII&7)", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &7速度: 2x", LoreBuilder.powerPerSecond(14)); - public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_3 = new SlimefunItemStack("ELECTRIC_INGOT_FACTORY_3", Material.RED_TERRACOTTA, "&c电动铸锭机 &7(&eIII&7)", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7速度: 8x", LoreBuilder.powerPerSecond(40)); - - //@Deprecated - //public static final SlimefunItemStack AUTOMATED_CRAFTING_CHAMBER = new SlimefunItemStack("AUTOMATED_CRAFTING_CHAMBER", Material.CRAFTING_TABLE, "&6自动合成机", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &710 J/个物品"); - - public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack("FLUID_PUMP", Material.BLUE_TERRACOTTA, "&9流体泵", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &732 J/个方块"); - public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack("CHARGING_BENCH", Material.CRAFTING_TABLE, "&6充电台", "", "&r能够给物品充电, 比如喷气背包", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &7128 J 可储存", "&8\u21E8 &e\u26A1 &7能源损失率: &c50%"); - - public static final SlimefunItemStack VANILLA_AUTO_CRAFTER = new SlimefunItemStack("VANILLA_AUTO_CRAFTER", HeadTexture.VANILLA_AUTO_CRAFTER, "&2自动合成机 &8(原版)", "", "&f将机器放在任意能装物品的方块上", "&f就能自动合成任何东西!", "&f可以合成 &e普通工作台 &f能合成的物品", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &7合成物品消耗 16 J"); - public static final SlimefunItemStack ENHANCED_AUTO_CRAFTER = new SlimefunItemStack("ENHANCED_AUTO_CRAFTER", HeadTexture.ENHANCED_AUTO_CRAFTER, "&2自动合成机 &8(高级)", "", "&f将机器放在任意能装物品的方块上", "&f就能自动合成任何东西!", "&f可以合成 &e高级工作台 &f能合成的物品", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &7合成物品消耗 16 J"); - public static final SlimefunItemStack ARMOR_AUTO_CRAFTER = new SlimefunItemStack("ARMOR_AUTO_CRAFTER", HeadTexture.ARMOR_AUTO_CRAFTER, "&2自动合成机 &8(盔甲锻造)", "", "&f将机器放在任意能装物品的方块上", "&f就能自动合成盔甲锻造台可以合成的东西", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &7合成物品消耗 32 J"); - - public static final SlimefunItemStack IRON_GOLEM_ASSEMBLER = new SlimefunItemStack("IRON_GOLEM_ASSEMBLER", Material.IRON_BLOCK, "&6铁傀儡装配机", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7冷却时间: &b30 秒", LoreBuilder.powerBuffer(4096), "&8\u21E8 &e\u26A1 &72048 J/个铁傀儡"); - public static final SlimefunItemStack WITHER_ASSEMBLER = new SlimefunItemStack("WITHER_ASSEMBLER", Material.OBSIDIAN, "&5凋灵装配机", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7冷却时间: &b30 秒", "&8\u21E8 &e\u26A1 &74096 J 可储存", "&8\u21E8 &e\u26A1 &74096 J/个凋灵"); - - public static final SlimefunItemStack TRASH_CAN = new SlimefunItemStack("TRASH_CAN_BLOCK", HeadTexture.TRASH_CAN, "&3垃圾箱", "", "&r可以把不要的物品放进这里"); - - public static final SlimefunItemStack ELYTRA_SCALE = new SlimefunItemStack("ELYTRA_SCALE", Material.FEATHER, "&b鞘翅鳞片"); - public static final SlimefunItemStack INFUSED_ELYTRA = new SlimefunItemStack("INFUSED_ELYTRA", Material.ELYTRA, "&5鞘翅 (经验修补)"); - public static final SlimefunItemStack SOULBOUND_ELYTRA = new SlimefunItemStack("SOULBOUND_ELYTRA", Material.ELYTRA, "&c鞘翅 (灵魂绑定)"); - - public static final SlimefunItemStack MAGNESIUM_SALT = new SlimefunItemStack("MAGNESIUM_SALT", Material.SUGAR, "&c镁盐", "", "&7是一种能在镁发电机中使用的特殊燃料"); - public static final SlimefunItemStack MAGNESIUM_GENERATOR = new SlimefunItemStack("MAGNESIUM_GENERATOR", HeadTexture.GENERATOR, "&c镁发电机", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(36)); + public static final SlimefunItemStack AUTO_BREEDER = new SlimefunItemStack( + "AUTO_BREEDER", + Material.HAY_BLOCK, + "&e自动喂食机", + "", + "&r需要 &a有机食物", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.powerBuffer(1024), + "&8\u21E8 &e\u26A1 &760 J/个动物"); + public static final SlimefunItemStack PRODUCE_COLLECTOR = new SlimefunItemStack( + "PRODUCE_COLLECTOR", + Material.HAY_BLOCK, + "&b全自动收集机", + "", + "&f此机器可以自动收取", + "&f附近动物生产的动物产品.", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + LoreBuilder.powerBuffer(512), + LoreBuilder.powerPerSecond(32)); + + public static final SlimefunItemStack ORGANIC_FOOD = + new SlimefunItemStack("ORGANIC_FOOD", HeadTexture.FILLED_CAN, "&a有机食物", "&7内含 &9???"); + public static final SlimefunItemStack WHEAT_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_WHEAT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9小麦"); + public static final SlimefunItemStack CARROT_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_CARROT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9胡萝卜"); + public static final SlimefunItemStack POTATO_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_POTATO", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9土豆"); + public static final SlimefunItemStack SEEDS_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_SEEDS", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9小麦种子"); + public static final SlimefunItemStack BEETROOT_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_BEETROOT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9甜菜"); + public static final SlimefunItemStack MELON_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_MELON", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9西瓜"); + public static final SlimefunItemStack APPLE_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_APPLE", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9苹果"); + public static final SlimefunItemStack SWEET_BERRIES_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_SWEET_BERRIES", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9浆果"); + public static final SlimefunItemStack KELP_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_KELP", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9干海带"); + public static final SlimefunItemStack COCOA_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_COCOA", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含 &9可可豆"); + public static final SlimefunItemStack SEAGRASS_ORGANIC_FOOD = new SlimefunItemStack( + "ORGANIC_FOOD_SEAGRASS", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7内含: &9海草"); + + public static final SlimefunItemStack FERTILIZER = + new SlimefunItemStack("FERTILIZER", HeadTexture.FILLED_CAN, "&a有机肥料", "&7内含 &9???"); + public static final SlimefunItemStack WHEAT_FERTILIZER = + new SlimefunItemStack("FERTILIZER_WHEAT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9小麦"); + public static final SlimefunItemStack CARROT_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_CARROT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9胡萝卜"); + public static final SlimefunItemStack POTATO_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_POTATO", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9土豆"); + public static final SlimefunItemStack SEEDS_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_SEEDS", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9小麦种子"); + public static final SlimefunItemStack BEETROOT_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_BEETROOT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9甜菜"); + public static final SlimefunItemStack MELON_FERTILIZER = + new SlimefunItemStack("FERTILIZER_MELON", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9西瓜"); + public static final SlimefunItemStack APPLE_FERTILIZER = + new SlimefunItemStack("FERTILIZER_APPLE", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9苹果"); + public static final SlimefunItemStack SWEET_BERRIES_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_SWEET_BERRIES", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9浆果"); + public static final SlimefunItemStack KELP_FERTILIZER = + new SlimefunItemStack("FERTILIZER_KELP", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9干海带"); + public static final SlimefunItemStack COCOA_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_COCOA", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含 &9可可豆"); + public static final SlimefunItemStack SEAGRASS_FERTILIZER = new SlimefunItemStack( + "FERTILIZER_SEAGRASS", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7内含: &9海草"); + + public static final SlimefunItemStack ANIMAL_GROWTH_ACCELERATOR = new SlimefunItemStack( + "ANIMAL_GROWTH_ACCELERATOR", + Material.HAY_BLOCK, + "&b动物生长加速器", + "", + "&r需要 &a有机食物", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.powerBuffer(1024), + LoreBuilder.powerPerSecond(28)); + public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR = new SlimefunItemStack( + "CROP_GROWTH_ACCELERATOR", + Material.LIME_TERRACOTTA, + "&a作物生长加速器", + "", + "&r需要 &a有机肥料", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7半径: 7x7", + "&8\u21E8 &7速度: &a3/次", + LoreBuilder.powerBuffer(1024), + "&8\u21E8 &e\u26A1 &750 J/s"); + public static final SlimefunItemStack CROP_GROWTH_ACCELERATOR_2 = new SlimefunItemStack( + "CROP_GROWTH_ACCELERATOR_2", + Material.LIME_TERRACOTTA, + "&a作物生长加速器 &7(&eII&7)", + "", + "&r需要 &a有机肥料", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7半径: 9x9", + "&8\u21E8 &7速度: &a4/次", + LoreBuilder.powerBuffer(1024), + "&8\u21E8 &e\u26A1 &760 J/s"); + public static final SlimefunItemStack TREE_GROWTH_ACCELERATOR = new SlimefunItemStack( + "TREE_GROWTH_ACCELERATOR", + Material.BROWN_TERRACOTTA, + "&a树木生长加速器", + "", + "&r需要 &a有机肥料", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7半径: 9x9", + "&8\u21E8 &7速度: &a4/次", + LoreBuilder.powerBuffer(1024), + LoreBuilder.powerPerSecond(48)); + + public static final SlimefunItemStack FOOD_FABRICATOR = new SlimefunItemStack( + "FOOD_FABRICATOR", + Material.GREEN_STAINED_GLASS, + "&c食品加工机", + "", + "&r可制造 &a有机食物", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(14)); + public static final SlimefunItemStack FOOD_FABRICATOR_2 = new SlimefunItemStack( + "FOOD_FABRICATOR_2", + Material.GREEN_STAINED_GLASS, + "&c食品加工机 &7(&eII&7)", + "", + "&r可制造 &a有机食物", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 6x", + LoreBuilder.powerBuffer(512), + LoreBuilder.powerPerSecond(48)); + + public static final SlimefunItemStack FOOD_COMPOSTER = new SlimefunItemStack( + "FOOD_COMPOSTER", + Material.GREEN_TERRACOTTA, + "&c食品堆肥器", + "", + "&r可制造 &a有机肥料", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(16)); + public static final SlimefunItemStack FOOD_COMPOSTER_2 = new SlimefunItemStack( + "FOOD_COMPOSTER_2", + Material.GREEN_TERRACOTTA, + "&c食品堆肥器 &7(&eII&7)", + "", + "&r可制造 &a有机肥料", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 10x", + LoreBuilder.powerBuffer(512), + "&8\u21E8 &e\u26A1 &752 J/s"); + + public static final SlimefunItemStack EXP_COLLECTOR = new SlimefunItemStack( + "XP_COLLECTOR", + HeadTexture.EXP_COLLECTOR, + "&a经验收集器", + "", + "&r收集附近的经验并储存它们", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.powerBuffer(1024), + LoreBuilder.powerPerSecond(20)); + public static final SlimefunItemStack REACTOR_COOLANT_CELL = + new SlimefunItemStack("REACTOR_COLLANT_CELL", HeadTexture.COOLANT_CELL, "&b反应堆冷却剂"); + + public static final SlimefunItemStack NUCLEAR_REACTOR = new SlimefunItemStack( + "NUCLEAR_REACTOR", + HeadTexture.NUCLEAR_REACTOR, + "&2核反应堆", + "", + "&r需要冷却剂!", + "&8\u21E8 &b必须被水包围", + "&8\u21E8 &b必须使用反应堆冷却剂工作", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), + "&8\u21E8 &e\u26A1 &716384 J 可储存", + "&8\u21E8 &e\u26A1 &7500 J/s"); + public static final SlimefunItemStack NETHER_STAR_REACTOR = new SlimefunItemStack( + "NETHERSTAR_REACTOR", + HeadTexture.NETHER_STAR_REACTOR, + "&r下界之星反应堆", + "", + "&r需要下界之星", + "&8\u21E8 &b必须被水包围", + "&8\u21E8 &b必须使用下界冰冷却剂工作", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.GENERATOR), + "&8\u21E8 &e\u26A1 &732768 J 可储存", + "&8\u21E8 &e\u26A1 &71024 J/s", + "&8\u21E8 &4会导致附近的生物获得凋零效果"); + public static final SlimefunItemStack REACTOR_ACCESS_PORT = new SlimefunItemStack( + "REACTOR_ACCESS_PORT", + Material.CYAN_TERRACOTTA, + "&2反应堆访问接口", + "", + "&r允许你通过货运节点来访问反应堆", + "&r也可以用于储存", + "", + "&8\u21E8 &c必须 &e放置在反应堆上方的第三格处"); + + public static final SlimefunItemStack FREEZER = new SlimefunItemStack( + "FREEZER", + Material.LIGHT_BLUE_STAINED_GLASS, + "&b冰箱", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(18)); + public static final SlimefunItemStack FREEZER_2 = new SlimefunItemStack( + "FREEZER_2", + Material.LIGHT_BLUE_STAINED_GLASS, + "&b冰箱 &7(&eII&7)", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 2x", + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(30)); + public static final SlimefunItemStack FREEZER_3 = new SlimefunItemStack( + "FREEZER_3", + Material.LIGHT_GRAY_STAINED_GLASS, + "&b冰箱 &7(&eIII&7)", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + LoreBuilder.speed(3), + LoreBuilder.powerBuffer(256), + LoreBuilder.powerPerSecond(42)); + + public static final SlimefunItemStack ELECTRIC_GOLD_PAN = new SlimefunItemStack( + "ELECTRIC_GOLD_PAN", + Material.BROWN_TERRACOTTA, + "&6电动淘金机", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(2)); + public static final SlimefunItemStack ELECTRIC_GOLD_PAN_2 = new SlimefunItemStack( + "ELECTRIC_GOLD_PAN_2", + Material.BROWN_TERRACOTTA, + "&6电动淘金机 &7(&eII&7)", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 3x", + LoreBuilder.powerPerSecond(4)); + public static final SlimefunItemStack ELECTRIC_GOLD_PAN_3 = new SlimefunItemStack( + "ELECTRIC_GOLD_PAN_3", + Material.BROWN_TERRACOTTA, + "&6电动淘金机 &7(&eIII&7)", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 10x", + LoreBuilder.powerPerSecond(14)); + + public static final SlimefunItemStack ELECTRIC_DUST_WASHER = new SlimefunItemStack( + "ELECTRIC_DUST_WASHER", + Material.BLUE_STAINED_GLASS, + "&3电动洗矿机", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(6)); + public static final SlimefunItemStack ELECTRIC_DUST_WASHER_2 = new SlimefunItemStack( + "ELECTRIC_DUST_WASHER_2", + Material.BLUE_STAINED_GLASS, + "&3电动洗矿机 &7(&eII&7)", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 2x", + LoreBuilder.powerPerSecond(10)); + public static final SlimefunItemStack ELECTRIC_DUST_WASHER_3 = new SlimefunItemStack( + "ELECTRIC_DUST_WASHER_3", + Material.BLUE_STAINED_GLASS, + "&3电动洗矿机 &7(&eIII&7)", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 10x", + LoreBuilder.powerPerSecond(30)); + + public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY = new SlimefunItemStack( + "ELECTRIC_INGOT_FACTORY", + Material.RED_TERRACOTTA, + "&c电动铸锭机", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 1x", + LoreBuilder.powerPerSecond(8)); + public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_2 = new SlimefunItemStack( + "ELECTRIC_INGOT_FACTORY_2", + Material.RED_TERRACOTTA, + "&c电动铸锭机 &7(&eII&7)", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &7速度: 2x", + LoreBuilder.powerPerSecond(14)); + public static final SlimefunItemStack ELECTRIC_INGOT_FACTORY_3 = new SlimefunItemStack( + "ELECTRIC_INGOT_FACTORY_3", + Material.RED_TERRACOTTA, + "&c电动铸锭机 &7(&eIII&7)", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7速度: 8x", + LoreBuilder.powerPerSecond(40)); + + // @Deprecated + // public static final SlimefunItemStack AUTOMATED_CRAFTING_CHAMBER = new + // SlimefunItemStack("AUTOMATED_CRAFTING_CHAMBER", Material.CRAFTING_TABLE, "&6自动合成机", "", + // LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &e\u26A1 &710 + // J/个物品"); + + public static final SlimefunItemStack FLUID_PUMP = new SlimefunItemStack( + "FLUID_PUMP", + Material.BLUE_TERRACOTTA, + "&9流体泵", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &e\u26A1 &732 J/个方块"); + public static final SlimefunItemStack CHARGING_BENCH = new SlimefunItemStack( + "CHARGING_BENCH", + Material.CRAFTING_TABLE, + "&6充电台", + "", + "&r能够给物品充电, 比如喷气背包", + "", + LoreBuilder.machine(MachineTier.BASIC, MachineType.MACHINE), + "&8\u21E8 &e\u26A1 &7128 J 可储存", + "&8\u21E8 &e\u26A1 &7能源损失率: &c50%"); + + public static final SlimefunItemStack VANILLA_AUTO_CRAFTER = new SlimefunItemStack( + "VANILLA_AUTO_CRAFTER", + HeadTexture.VANILLA_AUTO_CRAFTER, + "&2自动合成机 &8(原版)", + "", + "&f将机器放在任意能装物品的方块上", + "&f就能自动合成任何东西!", + "&f可以合成 &e普通工作台 &f能合成的物品", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &e\u26A1 &7合成物品消耗 16 J"); + public static final SlimefunItemStack ENHANCED_AUTO_CRAFTER = new SlimefunItemStack( + "ENHANCED_AUTO_CRAFTER", + HeadTexture.ENHANCED_AUTO_CRAFTER, + "&2自动合成机 &8(高级)", + "", + "&f将机器放在任意能装物品的方块上", + "&f就能自动合成任何东西!", + "&f可以合成 &e高级工作台 &f能合成的物品", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &e\u26A1 &7合成物品消耗 16 J"); + public static final SlimefunItemStack ARMOR_AUTO_CRAFTER = new SlimefunItemStack( + "ARMOR_AUTO_CRAFTER", + HeadTexture.ARMOR_AUTO_CRAFTER, + "&2自动合成机 &8(盔甲锻造)", + "", + "&f将机器放在任意能装物品的方块上", + "&f就能自动合成盔甲锻造台可以合成的东西", + "", + LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), + "&8\u21E8 &e\u26A1 &7合成物品消耗 32 J"); + + public static final SlimefunItemStack IRON_GOLEM_ASSEMBLER = new SlimefunItemStack( + "IRON_GOLEM_ASSEMBLER", + Material.IRON_BLOCK, + "&6铁傀儡装配机", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7冷却时间: &b30 秒", + LoreBuilder.powerBuffer(4096), + "&8\u21E8 &e\u26A1 &72048 J/个铁傀儡"); + public static final SlimefunItemStack WITHER_ASSEMBLER = new SlimefunItemStack( + "WITHER_ASSEMBLER", + Material.OBSIDIAN, + "&5凋灵装配机", + "", + LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), + "&8\u21E8 &7冷却时间: &b30 秒", + "&8\u21E8 &e\u26A1 &74096 J 可储存", + "&8\u21E8 &e\u26A1 &74096 J/个凋灵"); + + public static final SlimefunItemStack TRASH_CAN = + new SlimefunItemStack("TRASH_CAN_BLOCK", HeadTexture.TRASH_CAN, "&3垃圾箱", "", "&r可以把不要的物品放进这里"); + + public static final SlimefunItemStack ELYTRA_SCALE = + new SlimefunItemStack("ELYTRA_SCALE", Material.FEATHER, "&b鞘翅鳞片"); + public static final SlimefunItemStack INFUSED_ELYTRA = + new SlimefunItemStack("INFUSED_ELYTRA", Material.ELYTRA, "&5鞘翅 (经验修补)"); + public static final SlimefunItemStack SOULBOUND_ELYTRA = + new SlimefunItemStack("SOULBOUND_ELYTRA", Material.ELYTRA, "&c鞘翅 (灵魂绑定)"); + + public static final SlimefunItemStack MAGNESIUM_SALT = + new SlimefunItemStack("MAGNESIUM_SALT", Material.SUGAR, "&c镁盐", "", "&7是一种能在镁发电机中使用的特殊燃料"); + public static final SlimefunItemStack MAGNESIUM_GENERATOR = new SlimefunItemStack( + "MAGNESIUM_GENERATOR", + HeadTexture.GENERATOR, + "&c镁发电机", + "", + LoreBuilder.machine(MachineTier.MEDIUM, MachineType.GENERATOR), + LoreBuilder.powerBuffer(128), + LoreBuilder.powerPerSecond(36)); // 别删 - public static final SlimefunItemStack CRAFTER_SMART_PORT = new SlimefunItemStack("CRAFTER_SMART_PORT", Material.LIME_STAINED_GLASS, "&a合成机智能交互接口", "", "&5可以根据合成表材料数量分配输入数量", "&5并拥有指定输出槽"); + public static final SlimefunItemStack CRAFTER_SMART_PORT = new SlimefunItemStack( + "CRAFTER_SMART_PORT", Material.LIME_STAINED_GLASS, "&a合成机智能交互接口", "", "&5可以根据合成表材料数量分配输入数量", "&5并拥有指定输出槽"); static { INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java index 90b56a76f5..953c374902 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/StartupWarnings.java @@ -1,17 +1,15 @@ package io.github.thebusybiscuit.slimefun4.implementation; +import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import java.util.logging.Level; import java.util.logging.Logger; - import javax.annotation.ParametersAreNonnullByDefault; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; - /** * This class stores some startup warnings we occasionally need to print. * If you setup your server the recommended way, you are never going to see * any of these messages. - * + * * @author TheBusyBiscuit * */ @@ -72,5 +70,4 @@ static void oldJavaVersion(Logger logger, int recommendedJavaVersion) { logger.log(Level.WARNING, PREFIX + "为了不影响您以后的正常使用,请尽快更新!"); logger.log(Level.WARNING, BORDER); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java index b6da5146bf..446fdcae1e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/CheatSheetSlimefunGuide.java @@ -40,7 +40,7 @@ public CheatSheetSlimefunGuide() { * The {@link Player} who opened his {@link SlimefunGuide} * @param profile * The {@link PlayerProfile} of the {@link Player} - * + * * @return a {@link List} of visible {@link ItemGroup} instances */ @Override @@ -75,4 +75,4 @@ public void createHeader(Player p, PlayerProfile profile, ChestMenu menu) { menu.addItem(1, ChestMenuUtils.getBackground()); menu.addMenuClickHandler(1, ChestMenuUtils.getEmptyClickHandler()); } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index a6d7777266..297b37199b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -1,28 +1,6 @@ package io.github.thebusybiscuit.slimefun4.implementation.guide; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import java.util.Locale; -import java.util.Optional; -import java.util.logging.Level; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.apache.commons.lang.Validate; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.Tag; -import org.bukkit.entity.Player; -import org.bukkit.inventory.Inventory; -import org.bukkit.inventory.ItemFlag; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.Recipe; -import org.bukkit.inventory.RecipeChoice; -import org.bukkit.inventory.RecipeChoice.MaterialChoice; - +import city.norain.slimefun4.VaultIntegration; import io.github.bakedlibs.dough.chat.ChatInput; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; @@ -49,17 +27,35 @@ import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem; - +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Locale; +import java.util.Optional; +import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; -import city.norain.slimefun4.VaultIntegration; +import org.apache.commons.lang.Validate; +import org.bukkit.ChatColor; +import org.bukkit.Material; +import org.bukkit.Tag; +import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.ItemFlag; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Recipe; +import org.bukkit.inventory.RecipeChoice; +import org.bukkit.inventory.RecipeChoice.MaterialChoice; /** * The {@link SurvivalSlimefunGuide} is the standard version of our {@link SlimefunGuide}. * It uses an {@link Inventory} to display {@link SlimefunGuide} contents. * * @author TheBusyBiscuit - * + * * @see SlimefunGuide * @see SlimefunGuideImplementation * @see CheatSheetSlimefunGuide @@ -103,7 +99,7 @@ protected final boolean isSurvivalMode() { * The {@link Player} who opened his {@link SlimefunGuide} * @param profile * The {@link PlayerProfile} of the {@link Player} - * + * * @return a {@link List} of visible {@link ItemGroup} instances */ protected @Nonnull List getVisibleItemGroups(@Nonnull Player p, @Nonnull PlayerProfile profile) { @@ -191,7 +187,9 @@ public void openMainMenu(PlayerProfile profile, int page) { } private void showItemGroup(ChestMenu menu, Player p, PlayerProfile profile, ItemGroup group, int index) { - if (!(group instanceof LockedItemGroup) || !isSurvivalMode() || ((LockedItemGroup) group).hasUnlocked(p, profile)) { + if (!(group instanceof LockedItemGroup) + || !isSurvivalMode() + || ((LockedItemGroup) group).hasUnlocked(p, profile)) { menu.addItem(index, group.getItem(p)); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { openItemGroup(profile, group, 1); @@ -211,7 +209,15 @@ private void showItemGroup(ChestMenu menu, Player p, PlayerProfile profile, Item lore.add(parent.getItem(p).getItemMeta().getDisplayName()); } - menu.addItem(index, new CustomItemStack(Material.BARRIER, "&4" + Slimefun.getLocalization().getMessage(p, "guide.locked") + " &7- &f" + group.getItem(p).getItemMeta().getDisplayName(), lore.toArray(new String[0]))); + menu.addItem( + index, + new CustomItemStack( + Material.BARRIER, + "&4" + + Slimefun.getLocalization().getMessage(p, "guide.locked") + + " &7- &f" + + group.getItem(p).getItemMeta().getDisplayName(), + lore.toArray(new String[0]))); menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); } } @@ -284,12 +290,24 @@ public void openItemGroup(PlayerProfile profile, ItemGroup itemGroup, int page) menu.open(p); } - private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, PlayerProfile profile, SlimefunItem sfitem, int page, int index) { + private void displaySlimefunItem( + ChestMenu menu, + ItemGroup itemGroup, + Player p, + PlayerProfile profile, + SlimefunItem sfitem, + int page, + int index) { Research research = sfitem.getResearch(); if (isSurvivalMode() && !hasPermission(p, sfitem)) { List message = Slimefun.getPermissionsService().getLore(sfitem); - menu.addItem(index, new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0]))); + menu.addItem( + index, + new CustomItemStack( + ChestMenuUtils.getNoPermissionItem(), + sfitem.getItemName(), + message.toArray(new String[0]))); menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); } else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { String lore; @@ -300,7 +318,18 @@ private void displaySlimefunItem(ChestMenu menu, ItemGroup itemGroup, Player p, lore = research.getLevelCost() + " 级经验"; } - menu.addItem(index, new CustomItemStack(new CustomItemStack(ChestMenuUtils.getNoPermissionItem(), "&f" + ItemUtils.getItemName(sfitem.getItem()), "&7" + sfitem.getId(), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", "&a> 单击解锁", "", "&7需要 &b", lore))); + menu.addItem( + index, + new CustomItemStack(new CustomItemStack( + ChestMenuUtils.getNoPermissionItem(), + "&f" + ItemUtils.getItemName(sfitem.getItem()), + "&7" + sfitem.getId(), + "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), + "", + "&a> 单击解锁", + "", + "&7需要 &b", + lore))); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { research.unlockFromGuide(this, p, profile, sfitem, itemGroup, page); return false; @@ -349,7 +378,9 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory return; } - ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.search.inventory").replace("%item%", ChatUtils.crop(ChatColor.WHITE, input))); + ChestMenu menu = new ChestMenu(Slimefun.getLocalization() + .getMessage(p, "guide.search.inventory") + .replace("%item%", ChatUtils.crop(ChatColor.WHITE, input))); String searchTerm = input.toLowerCase(Locale.ROOT); if (addToHistory) { @@ -367,10 +398,13 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory break; } - if (!slimefunItem.isHidden() && isItemGroupAccessible(p, slimefunItem) && isSearchFilterApplicable(slimefunItem, searchTerm)) { + if (!slimefunItem.isHidden() + && isItemGroupAccessible(p, slimefunItem) + && isSearchFilterApplicable(slimefunItem, searchTerm)) { ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> { ItemGroup itemGroup = slimefunItem.getItemGroup(); - meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); + meta.setLore(Arrays.asList( + "", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p))); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS); }); @@ -398,7 +432,8 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory @ParametersAreNonnullByDefault private boolean isItemGroupAccessible(Player p, SlimefunItem slimefunItem) { - return Slimefun.getConfigManager().isShowHiddenItemGroupsInSearch() || slimefunItem.getItemGroup().isAccessible(p); + return Slimefun.getConfigManager().isShowHiddenItemGroupsInSearch() + || slimefunItem.getItemGroup().isAccessible(p); } @ParametersAreNonnullByDefault @@ -436,7 +471,8 @@ public void displayItem(PlayerProfile profile, ItemStack item, int index, boolea showMinecraftRecipe(recipes, index, item, profile, p, addToHistory); } - private void showMinecraftRecipe(Recipe[] recipes, int index, ItemStack item, PlayerProfile profile, Player p, boolean addToHistory) { + private void showMinecraftRecipe( + Recipe[] recipes, int index, ItemStack item, PlayerProfile profile, Player p, boolean addToHistory) { Recipe recipe = recipes[index]; ItemStack[] recipeItems = new ItemStack[9]; @@ -452,7 +488,17 @@ private void showMinecraftRecipe(Recipe[] recipes, int index, ItemStack item, Pl recipeType = new RecipeType(optional.get()); result = recipe.getResult(); } else { - recipeItems = new ItemStack[] { null, null, null, null, new CustomItemStack(Material.BARRIER, "&4We are somehow unable to show you this Recipe :/"), null, null, null, null }; + recipeItems = new ItemStack[] { + null, + null, + null, + null, + new CustomItemStack(Material.BARRIER, "&4We are somehow unable to show you this Recipe :/"), + null, + null, + null, + null + }; } ChestMenu menu = create(p); @@ -468,12 +514,13 @@ private void showMinecraftRecipe(Recipe[] recipes, int index, ItemStack item, Pl menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } - menu.addItem(28, ChestMenuUtils.getPreviousButton(p, index + 1, recipes.length), (pl, slot, action, stack) -> { - if (index > 0) { - showMinecraftRecipe(recipes, index - 1, item, profile, p, true); - } - return false; - }); + menu.addItem( + 28, ChestMenuUtils.getPreviousButton(p, index + 1, recipes.length), (pl, slot, action, stack) -> { + if (index > 0) { + showMinecraftRecipe(recipes, index - 1, item, profile, p, true); + } + return false; + }); menu.addItem(34, ChestMenuUtils.getNextButton(p, index + 1, recipes.length), (pl, slot, action, stack) -> { if (index < recipes.length - 1) { @@ -525,7 +572,16 @@ public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToH Optional wiki = item.getWikipage(); if (wiki.isPresent()) { - menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK, ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); + menu.addItem( + 8, + new CustomItemStack( + Material.KNOWLEDGE_BOOK, + ChatColor.WHITE + Slimefun.getLocalization().getMessage(p, "guide.tooltips.wiki"), + "", + ChatColor.GRAY + + "\u21E8 " + + ChatColor.GREEN + + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-itemgroup"))); menu.addMenuClickHandler(8, (pl, slot, itemstack, action) -> { pl.closeInventory(); ChatUtils.sendURL(pl, wiki.get()); @@ -556,7 +612,15 @@ public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToH } } - private void displayItem(ChestMenu menu, PlayerProfile profile, Player p, Object item, ItemStack output, RecipeType recipeType, ItemStack[] recipe, AsyncRecipeChoiceTask task) { + private void displayItem( + ChestMenu menu, + PlayerProfile profile, + Player p, + Object item, + ItemStack output, + RecipeType recipeType, + ItemStack[] recipe, + AsyncRecipeChoiceTask task) { addBackButton(menu, 0, p, profile); MenuClickHandler clickHandler = (pl, slot, itemstack, action) -> { @@ -613,7 +677,10 @@ public void createHeader(Player p, PlayerProfile profile, ChestMenu menu) { pl.closeInventory(); Slimefun.getLocalization().sendMessage(pl, "guide.search.message"); - ChatInput.waitForPlayer(Slimefun.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, getMode(), isSurvivalMode())); + ChatInput.waitForPlayer( + Slimefun.instance(), + pl, + msg -> SlimefunGuide.openSearch(profile, msg, getMode(), isSurvivalMode())); return false; }); @@ -627,7 +694,9 @@ private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile pro GuideHistory history = profile.getGuideHistory(); if (isSurvivalMode() && history.size() > 1) { - menu.addItem(slot, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&f左键: &7返回上一页", "&fShift + 左键: &7返回主菜单"))); + menu.addItem( + slot, + new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&f左键: &7返回上一页", "&fShift + 左键: &7返回主菜单"))); menu.addMenuClickHandler(slot, (pl, s, is, action) -> { if (action.isShiftClicked()) { @@ -639,7 +708,10 @@ private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile pro }); } else { - menu.addItem(slot, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); + menu.addItem( + slot, + new CustomItemStack(ChestMenuUtils.getBackButton( + p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide")))); menu.addMenuClickHandler(slot, (pl, s, is, action) -> { openMainMenu(profile, profile.getGuideHistory().getMainMenuPage()); return false; @@ -656,8 +728,17 @@ private void addBackButton(ChestMenu menu, int slot, Player p, PlayerProfile pro return item; } - String lore = hasPermission(p, slimefunItem) ? "&f需要在 " + slimefunItem.getItemGroup().getDisplayName(p) + " 中解锁" : "&f无权限"; - return slimefunItem.canUse(p, false) ? item : new CustomItemStack(Material.BARRIER, ItemUtils.getItemName(item), "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), "", lore); + String lore = hasPermission(p, slimefunItem) + ? "&f需要在 " + slimefunItem.getItemGroup().getDisplayName(p) + " 中解锁" + : "&f无权限"; + return slimefunItem.canUse(p, false) + ? item + : new CustomItemStack( + Material.BARRIER, + ItemUtils.getItemName(item), + "&4&l" + Slimefun.getLocalization().getMessage(p, "guide.locked"), + "", + lore); } else { return item; } @@ -672,7 +753,8 @@ private void displayRecipes(Player p, PlayerProfile profile, ChestMenu menu, Rec if (page == 0) { for (int i = 27; i < 36; i++) { - menu.replaceExistingItem(i, new CustomItemStack(ChestMenuUtils.getBackground(), sfItem.getRecipeSectionLabel(p))); + menu.replaceExistingItem( + i, new CustomItemStack(ChestMenuUtils.getBackground(), sfItem.getRecipeSectionLabel(p))); menu.addMenuClickHandler(i, ChestMenuUtils.getEmptyClickHandler()); } } @@ -718,7 +800,8 @@ private void displayRecipes(Player p, PlayerProfile profile, ChestMenu menu, Rec } } - private void addDisplayRecipe(ChestMenu menu, PlayerProfile profile, List recipes, int slot, int i, int page) { + private void addDisplayRecipe( + ChestMenu menu, PlayerProfile profile, List recipes, int slot, int i, int page) { if ((i + (page * 18)) < recipes.size()) { ItemStack displayItem = recipes.get(i + (page * 18)); @@ -765,8 +848,10 @@ private void printErrorMessage(Player p, Throwable x) { @ParametersAreNonnullByDefault private void printErrorMessage(Player p, SlimefunItem item, Throwable x) { - p.sendMessage(ChatColor.DARK_RED + "An internal server error has occurred. Please inform an admin, check the console for further info."); - item.error("This item has caused an error message to be thrown while viewing it in the Slimefun guide.", x); + p.sendMessage(ChatColor.DARK_RED + + "An internal server error has occurred. Please inform an admin, check the console for" + + " further info."); + item.error( + "This item has caused an error message to be thrown while viewing it in the Slimefun" + " guide.", x); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java index 231751cda5..c27e78c613 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/package-info.java @@ -2,4 +2,4 @@ * This package provides the different implementations of our * {@link io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide} */ -package io.github.thebusybiscuit.slimefun4.implementation.guide; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.implementation.guide; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java index f8986c9a70..0070bda7fd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/SimpleBlockBreakHandler.java @@ -3,14 +3,13 @@ import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; +import java.util.List; +import javax.annotation.Nonnull; import org.bukkit.block.Block; import org.bukkit.entity.Player; import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import java.util.List; - /** * This simple implementation of {@link BlockBreakHandler} will execute the same code * for when the {@link Block} is broken by a {@link Player}, by a {@link MinerAndroid} or an explosion. @@ -53,5 +52,4 @@ public void onAndroidBreak(AndroidMineEvent e) { public void onExplode(Block b, List drops) { onBlockBreak(b); } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java index 7ead892718..8d830acf92 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/VanillaInventoryDropHandler.java @@ -1,10 +1,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.handlers; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; +import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; +import io.papermc.lib.PaperLib; import java.util.List; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.block.Block; import org.bukkit.block.BlockState; @@ -14,24 +15,20 @@ import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; -import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; -import io.papermc.lib.PaperLib; - /** * This is an implementation of {@link BlockBreakHandler} which is suited for any {@link SlimefunItem} * that uses the vanilla {@link Inventory} from the {@link BlockState}. *

    * The default behaviour is the following: - * + * *

    -| Broken by... | Behaviour                |
    -| ------------ | ------------------------ |
    -| Player       | Drop inventory contents. |
    -| Android      | Not allowed.             |
    -| Explosions   | Delete contents.         |
    + * | Broken by... | Behaviour                |
    + * | ------------ | ------------------------ |
    + * | Player       | Drop inventory contents. |
    + * | Android      | Not allowed.             |
    + * | Explosions   | Delete contents.         |
      * 
    - * + * * @author TheBusyBiscuit * * @param @@ -43,7 +40,7 @@ public class VanillaInventoryDropHandler /** * This creates a new {@link VanillaInventoryDropHandler} for the given {@link BlockState} {@link Class}. - * + * * @param blockStateClass * The class of the block's {@link BlockState} */ @@ -84,5 +81,4 @@ protected Inventory getInventory(@Nonnull T inventoryHolder) { return inventoryHolder.getInventory(); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java index 2afaa20dce..ccaaab90df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/handlers/package-info.java @@ -2,4 +2,4 @@ * This package holds simple implementations of {@link io.github.thebusybiscuit.slimefun4.api.items.ItemHandler}. * These are just handlers that can be re-used frequently. */ -package io.github.thebusybiscuit.slimefun4.implementation.handlers; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.implementation.handlers; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java index a7525c9971..ef487e577a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/EnchantedItem.java @@ -1,21 +1,16 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * The {@link EnchantedItem} is an enchanted {@link SlimefunItem}. * By default, this class sets items to be not disenchantable. - * + * * @author Fury_Phoenix * */ @@ -26,5 +21,4 @@ public EnchantedItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType rec super(itemGroup, item, recipeType, recipe); disenchantable = false; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java index dcfaa8a103..03720b47ef 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/HiddenItem.java @@ -1,21 +1,19 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * The {@link HiddenItem} is a {@link NotConfigurable} {@link SlimefunItem} * that is hidden from the Slimefun guide. - * + * * @author char321 - * + * */ public class HiddenItem extends SlimefunItem implements NotConfigurable { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java index b37bc99edc..d70862b117 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/LimitedUseItem.java @@ -1,11 +1,20 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; +import io.github.bakedlibs.dough.common.ChatColors; +import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; +import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; +import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; import java.util.Collections; import java.util.List; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.Material; import org.bukkit.NamespacedKey; @@ -15,18 +24,6 @@ import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataType; -import io.github.bakedlibs.dough.common.ChatColors; -import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.staves.StormStaff; -import io.github.thebusybiscuit.slimefun4.utils.LoreBuilder; -import io.github.thebusybiscuit.slimefun4.utils.PatternUtils; - /** * This class represents an item with a limited number of uses. * When the item runs out of "uses", it breaks. @@ -88,7 +85,8 @@ public final int getMaxUseCount() { @Override public void register(@Nonnull SlimefunAddon addon) { if (getMaxUseCount() < 1) { - warn("The use count has not been configured correctly. It needs to be at least 1. The Item was disabled."); + warn("The use count has not been configured correctly. It needs to be at least 1. The Item was" + + " disabled."); } else { super.register(addon); } @@ -148,5 +146,4 @@ private void updateItemLore(ItemStack item, ItemMeta meta, int usesLeft) { item.setItemMeta(meta); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java index 0a08ae0eff..86f380a5e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/RadioactiveItem.java @@ -1,11 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; @@ -15,16 +9,20 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * A quick and easy implementation of {@link SlimefunItem} that also implements the * interface {@link Radioactive}. * This implementation is {@link NotPlaceable}! - * + * * Simply specify a level of {@link Radioactivity} in the constructor. - * + * * @author TheBusyBiscuit - * + * * @see Radioactive * @see Radioactivity * @@ -38,7 +36,7 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla /** * This will create a new {@link RadioactiveItem} with the given level of {@link Radioactivity} - * + * * @param itemGroup * The {@link ItemGroup} of this {@link SlimefunItem} * @param radioactivity @@ -51,13 +49,18 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla * The recipe of how to craft this {@link SlimefunItem} */ @ParametersAreNonnullByDefault - public RadioactiveItem(ItemGroup itemGroup, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public RadioactiveItem( + ItemGroup itemGroup, + Radioactivity radioactivity, + SlimefunItemStack item, + RecipeType recipeType, + ItemStack[] recipe) { this(itemGroup, radioactivity, item, recipeType, recipe, null); } /** * This will create a new {@link RadioactiveItem} with the given level of {@link Radioactivity} - * + * * @param itemGroup * The {@link ItemGroup} of this {@link SlimefunItem} * @param radioactivity @@ -72,7 +75,13 @@ public RadioactiveItem(ItemGroup itemGroup, Radioactivity radioactivity, Slimefu * The recipe output */ @ParametersAreNonnullByDefault - public RadioactiveItem(ItemGroup itemGroup, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) { + public RadioactiveItem( + ItemGroup itemGroup, + Radioactivity radioactivity, + SlimefunItemStack item, + RecipeType recipeType, + ItemStack[] recipe, + @Nullable ItemStack recipeOutput) { super(itemGroup, item, recipeType, recipe, recipeOutput); this.radioactivity = radioactivity; @@ -89,5 +98,4 @@ private ItemUseHandler onRightClick() { public Radioactivity getRadioactivity() { return radioactivity; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java index 839a3ce053..899dca241c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/SimpleSlimefunItem.java @@ -1,27 +1,25 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * This is basically a quickstart class for your very first {@link SlimefunItem}. * This class easily allows you to add one {@link ItemHandler} to your {@link SlimefunItem}. - * + * * You could use an {@link ItemUseHandler} for example to give your {@link SlimefunItem} * very basic right-click functionalities. - * + * * @author TheBusyBiscuit - * + * * @see ItemHandler * @see ItemUseHandler * @see SlimefunItem @@ -32,12 +30,18 @@ public abstract class SimpleSlimefunItem extends SlimefunItem { @ParametersAreNonnullByDefault - protected SimpleSlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + protected SimpleSlimefunItem( + ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); } @ParametersAreNonnullByDefault - protected SimpleSlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) { + protected SimpleSlimefunItem( + ItemGroup itemGroup, + SlimefunItemStack item, + RecipeType recipeType, + ItemStack[] recipe, + @Nullable ItemStack recipeOutput) { super(itemGroup, item, recipeType, recipe, recipeOutput); } @@ -48,9 +52,8 @@ public void preRegister() { /** * This returns the {@link ItemHandler} that will be added to this {@link SlimefunItem}. - * + * * @return The {@link ItemHandler} that should be added to this {@link SlimefunItem} */ public abstract @Nonnull T getItemHandler(); - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java index 7d6291b91a..3d652598cd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/VanillaItem.java @@ -1,13 +1,11 @@ package io.github.thebusybiscuit.slimefun4.implementation.items; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemState; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * Represents a vanilla item that is overridden by Slimefun (like {@code ELYTRA}). @@ -16,11 +14,11 @@ * When a {@link VanillaItem} gets disabled, its {@link ItemState} goes on {@code State.VANILLA} which * automatically * replace it in the recipes by its vanilla equivalent. - * + * * A {@link VanillaItem} is also automatically useable in workbenches. * * @author TheBusyBiscuit - * + * * @see SlimefunItem * */ diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java index 67ab01a0e8..2a1a7ce8b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AltarRecipe.java @@ -42,7 +42,9 @@ public List getInput() { @Override public boolean equals(Object obj) { if (obj instanceof AltarRecipe ar) { - return ar.getCatalyst().equals(getCatalyst()) && ar.getInput().equals(getInput()) && ar.getOutput().equals(getOutput()); + return ar.getCatalyst().equals(getCatalyst()) + && ar.getInput().equals(getInput()) + && ar.getOutput().equals(getOutput()); } else { return false; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java index 40e03c34ec..de9fbce093 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientAltar.java @@ -1,13 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.altar; -import java.util.ArrayList; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.events.AncientAltarCraftEvent; import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; @@ -17,6 +9,11 @@ import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener; import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; +import java.util.ArrayList; +import java.util.List; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.inventory.ItemStack; /** * The {@link AncientAltar} is a multiblock structure. @@ -42,7 +39,8 @@ public class AncientAltar extends SlimefunItem { private final List recipes = new ArrayList<>(); - private final ItemSetting stepDelay = new IntRangeSetting(this, "step-delay", 0, DEFAULT_STEP_DELAY, Integer.MAX_VALUE); + private final ItemSetting stepDelay = + new IntRangeSetting(this, "step-delay", 0, DEFAULT_STEP_DELAY, Integer.MAX_VALUE); @ParametersAreNonnullByDefault public AncientAltar(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { @@ -66,5 +64,4 @@ public int getStepDelay() { public List getRecipes() { return recipes; } - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java index 99a7b15585..952d397f15 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java @@ -1,22 +1,5 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.altar; -import java.util.Optional; - -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.GameMode; -import org.bukkit.Location; -import org.bukkit.block.Block; -import org.bukkit.entity.ArmorStand; -import org.bukkit.entity.Entity; -import org.bukkit.entity.Item; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; -import org.bukkit.util.Vector; - import io.github.bakedlibs.dough.common.ChatColors; import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.bakedlibs.dough.items.ItemUtils; @@ -35,16 +18,30 @@ import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask; import io.github.thebusybiscuit.slimefun4.utils.ArmorStandUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; +import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.GameMode; +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Entity; +import org.bukkit.entity.Item; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.meta.ItemMeta; +import org.bukkit.util.Vector; /** * The {@link AncientPedestal} is a part of the {@link AncientAltar}. * You can place any {@link ItemStack} onto the {@link AncientPedestal} to provide it to * the altar as a crafting ingredient. - * + * * @author Redemption198 * @author TheBusyBiscuit * @author JustAHuman - * + * * @see AncientAltar * @see AncientAltarListener * @see AncientAltarTask @@ -55,7 +52,12 @@ public class AncientPedestal extends SimpleSlimefunItem im public static final String ITEM_PREFIX = ChatColors.color("&dALTAR &3Probe - &e"); @ParametersAreNonnullByDefault - public AncientPedestal(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + public AncientPedestal( + ItemGroup itemGroup, + SlimefunItemStack item, + RecipeType recipeType, + ItemStack[] recipe, + ItemStack recipeOutput) { super(itemGroup, item, recipeType, recipe, recipeOutput); addItemHandler(onBreak()); @@ -68,7 +70,7 @@ public AncientPedestal(ItemGroup itemGroup, SlimefunItemStack item, RecipeType r public void onBlockBreak(@Nonnull Block b) { Optional entity = getPlacedItem(b); ArmorStand armorStand = getArmorStand(b, false); - + if (entity.isPresent()) { Item stack = entity.get(); @@ -78,7 +80,7 @@ public void onBlockBreak(@Nonnull Block b) { stack.remove(); } } - + if (armorStand != null && armorStand.isValid()) { armorStand.remove(); } @@ -102,21 +104,21 @@ public void onBlockBreak(@Nonnull Block b) { return Optional.empty(); } - + public @Nullable ArmorStand getArmorStand(@Nonnull Block pedestal, boolean createIfNoneExists) { Optional entity = getPlacedItem(pedestal); - + if (entity.isPresent() && entity.get().getVehicle() instanceof ArmorStand armorStand) { return armorStand; } - + Location l = pedestal.getLocation().add(0.5, 1.2, 0.5); for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, this::testArmorStand)) { if (n instanceof ArmorStand armorStand) { return armorStand; } } - + return createIfNoneExists ? ArmorStandUtils.spawnArmorStand(l) : null; } @@ -129,7 +131,7 @@ public static boolean testItem(@Nullable Entity n) { return false; } } - + private boolean testArmorStand(@Nullable Entity n) { if (n instanceof ArmorStand && n.isValid()) { String customName = n.getCustomName(); @@ -167,7 +169,8 @@ public void placeItem(@Nonnull Player p, @Nonnull Block b) { ItemUtils.consumeItem(hand, false); } - Item entity = SlimefunUtils.spawnItem(b.getLocation().add(0.5, 1.2, 0.5), displayItem, ItemSpawnReason.ANCIENT_PEDESTAL_PLACE_ITEM); + Item entity = SlimefunUtils.spawnItem( + b.getLocation().add(0.5, 1.2, 0.5), displayItem, ItemSpawnReason.ANCIENT_PEDESTAL_PLACE_ITEM); if (entity != null) { ArmorStand armorStand = getArmorStand(b, true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java index 5e588c64bb..fd28d71250 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/package-info.java @@ -2,4 +2,4 @@ * This package holds the {@link io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem} implementations related to * the {@link io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar}. */ -package io.github.thebusybiscuit.slimefun4.implementation.items.altar; \ No newline at end of file +package io.github.thebusybiscuit.slimefun4.implementation.items.altar; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java index 0dc0e77da9..a7aea4acb5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidAction.java @@ -8,5 +8,4 @@ interface AndroidAction { void perform(ProgrammableAndroid android, Block b, BlockMenu inventory, BlockFace face); - -} \ No newline at end of file +} diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java index d3c313b76b..5c3166c733 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidFuelSource.java @@ -1,15 +1,13 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; -import javax.annotation.Nonnull; - -import org.bukkit.inventory.ItemStack; - import io.github.bakedlibs.dough.items.CustomItemStack; import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import javax.annotation.Nonnull; +import org.bukkit.inventory.ItemStack; /** * This enum covers all different fuel sources a {@link ProgrammableAndroid} can have. - * + * * @author TheBusyBiscuit * */ @@ -38,12 +36,11 @@ public enum AndroidFuelSource { /** * This returns a display {@link ItemStack} for this {@link AndroidFuelSource}. - * + * * @return An {@link ItemStack} to display */ @Nonnull public ItemStack getItem() { return new CustomItemStack(HeadTexture.GENERATOR.getAsItemStack(), "&8\u21E9 &c燃料输入槽 &8\u21E9", lore); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java index ff68ea759a..95bd7d1044 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInstance.java @@ -19,5 +19,4 @@ public ProgrammableAndroid getAndroid() { public Block getBlock() { return b; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java index ec21c6a83b..e2f3ca4ec6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidInterface.java @@ -1,23 +1,21 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; -import javax.annotation.ParametersAreNonnullByDefault; - -import org.bukkit.block.Dispenser; -import org.bukkit.inventory.ItemStack; - import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler; import io.github.thebusybiscuit.slimefun4.implementation.handlers.VanillaInventoryDropHandler; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; +import javax.annotation.ParametersAreNonnullByDefault; +import org.bukkit.block.Dispenser; +import org.bukkit.inventory.ItemStack; /** * The {@link AndroidInterface} are inventories used to interact with a {@link ProgrammableAndroid}. * There are two variants of interfaces, fuel and items. - * + * * @author TheBusyBiscuit - * + * * @see ProgrammableAndroid * */ @@ -34,5 +32,4 @@ public AndroidInterface(ItemGroup itemGroup, SlimefunItemStack item, RecipeType public BlockDispenseHandler getItemHandler() { return (e, d, block, machine) -> e.setCancelled(true); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java index 698872a6b6..b32366e2e0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/AndroidType.java @@ -58,5 +58,4 @@ public enum AndroidType { boolean isType(@Nonnull AndroidType type) { return type == NONE || type == this || (type == NON_FIGHTER && this != FIGHTER); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java index 87e59775b3..bd607730ca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ButcherAndroid.java @@ -6,6 +6,9 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.UUID; +import java.util.function.Predicate; +import javax.annotation.ParametersAreNonnullByDefault; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; @@ -17,16 +20,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.metadata.FixedMetadataValue; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.UUID; -import java.util.function.Predicate; - public class ButcherAndroid extends ProgrammableAndroid { private static final String METADATA_KEY = "android_killer"; @ParametersAreNonnullByDefault - public ButcherAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public ButcherAndroid( + ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, tier, item, recipeType, recipe); } @@ -40,22 +40,34 @@ protected void attack(Block b, BlockFace face, Predicate predicate double damage = getTier() >= 3 ? 20D : 4D * getTier(); double radius = 4.0 + getTier(); - for (Entity n : b.getWorld().getNearbyEntities(b.getLocation(), radius, radius, radius, n -> n instanceof LivingEntity livingEntity && !(n instanceof ArmorStand) && !(n instanceof Player) && n.isValid() && predicate.test(livingEntity))) { + for (Entity n : b.getWorld() + .getNearbyEntities( + b.getLocation(), + radius, + radius, + radius, + n -> n instanceof LivingEntity livingEntity + && !(n instanceof ArmorStand) + && !(n instanceof Player) + && n.isValid() + && predicate.test(livingEntity))) { // Check if our android is facing this entity. - boolean willAttack = switch (face) { - case NORTH -> n.getLocation().getZ() < b.getZ(); - case EAST -> n.getLocation().getX() > b.getX(); - case SOUTH -> n.getLocation().getZ() > b.getZ(); - case WEST -> n.getLocation().getX() < b.getX(); - default -> false; - }; + boolean willAttack = + switch (face) { + case NORTH -> n.getLocation().getZ() < b.getZ(); + case EAST -> n.getLocation().getX() > b.getX(); + case SOUTH -> n.getLocation().getZ() > b.getZ(); + case WEST -> n.getLocation().getX() < b.getX(); + default -> false; + }; if (willAttack) { if (n.hasMetadata(METADATA_KEY)) { n.removeMetadata(METADATA_KEY, Slimefun.instance()); } - OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); + OfflinePlayer owner = + Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); if (!Slimefun.getProtectionManager().hasPermission(owner, n.getLocation(), Interaction.ATTACK_ENTITY)) { return; } @@ -67,5 +79,4 @@ protected void attack(Block b, BlockFace face, Predicate predicate } } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java index b530330a6c..ec94ac2dc0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FarmerAndroid.java @@ -7,6 +7,10 @@ import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.ThreadLocalRandom; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Bukkit; import org.bukkit.Effect; @@ -17,15 +21,11 @@ import org.bukkit.block.data.BlockData; import org.bukkit.inventory.ItemStack; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.ThreadLocalRandom; - public class FarmerAndroid extends ProgrammableAndroid { @ParametersAreNonnullByDefault - public FarmerAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public FarmerAndroid( + ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, tier, item, recipeType, recipe); } @@ -37,7 +37,8 @@ public AndroidType getAndroidType() { @Override protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) { - OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); + OfflinePlayer owner = + Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); if (!Slimefun.getProtectionManager().hasPermission(owner, block, Interaction.BREAK_BLOCK)) { return; } @@ -87,5 +88,4 @@ private ItemStack getDropFromCrop(Material crop) { default -> null; }; } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java index a6ce80e2fe..6ea86da447 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/FishermanAndroid.java @@ -1,29 +1,26 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +import io.github.bakedlibs.dough.collections.RandomizedSet; +import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; +import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; +import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; +import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; import java.util.concurrent.ThreadLocalRandom; - import javax.annotation.ParametersAreNonnullByDefault; - +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.inventory.ItemStack; -import io.github.bakedlibs.dough.collections.RandomizedSet; -import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; -import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; -import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; -import io.github.thebusybiscuit.slimefun4.core.services.sounds.SoundEffect; - -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; - public class FishermanAndroid extends ProgrammableAndroid { private final RandomizedSet fishingLoot = new RandomizedSet<>(); @ParametersAreNonnullByDefault - public FishermanAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public FishermanAndroid( + ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, tier, item, recipeType, recipe); // Fish diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java index 03fba08cff..5a611ccfa6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Instruction.java @@ -1,13 +1,14 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import java.util.HashMap; import java.util.Map; import java.util.function.Predicate; - import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.ParametersAreNonnullByDefault; - +import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.apache.commons.lang.Validate; import org.bukkit.Location; import org.bukkit.block.Block; @@ -18,15 +19,10 @@ import org.bukkit.entity.Monster; import org.bukkit.inventory.ItemStack; -import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; -import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; - -import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; - /** * This enum holds every {@link Instruction} for the {@link ProgrammableAndroid} * added by Slimefun itself. - * + * * @author TheBusyBiscuit * */ @@ -208,7 +204,7 @@ public enum Instruction { /** * This {@link Instruction} will make a {@link FarmerAndroid} try to harvest * the {@link Block} in front of them. - * + * * This includes plants from ExoticGarden. */ FARM_EXOTIC_FORWARD(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> { @@ -219,7 +215,7 @@ public enum Instruction { /** * This {@link Instruction} will make a {@link FarmerAndroid} try to harvest * the {@link Block} below. - * + * * This includes plants from ExoticGarden. */ FARM_EXOTIC_DOWN(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> { @@ -294,11 +290,10 @@ public void execute(ProgrammableAndroid android, Block b, BlockMenu inventory, B * * @param value * The value which you would like to look up. - * + * * @return The {@link Instruction} or null if it does not exist. */ - @Nullable - public static Instruction getInstruction(@Nonnull String value) { + @Nullable public static Instruction getInstruction(@Nonnull String value) { Validate.notNull(value, "An Instruction cannot be null!"); return nameLookup.get(value); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java index 46662f5732..cb06c746da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java @@ -11,23 +11,21 @@ import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; import io.github.thebusybiscuit.slimefun4.utils.InfiniteBlockGenerator; import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag; +import java.util.Collection; +import java.util.UUID; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; import org.bukkit.Bukkit; import org.bukkit.Effect; import org.bukkit.Material; import org.bukkit.OfflinePlayer; import org.bukkit.Particle; -import org.bukkit.Sound; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Container; import org.bukkit.inventory.ItemStack; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.Collection; -import java.util.UUID; - /** * The {@link MinerAndroid} is a variant of the {@link ProgrammableAndroid} which * is able to break blocks. @@ -36,7 +34,7 @@ * Otherwise the functionality is similar to a regular android. *

    * The {@link MinerAndroid} will also fire an {@link AndroidMineEvent} when breaking a {@link Block}. - * + * * @author TheBusyBiscuit * @author creator3 * @author poma123 @@ -44,7 +42,7 @@ * @author CyberPatriot * @author Redemption198 * @author Poslovitch - * + * * @see AndroidMineEvent * */ @@ -57,7 +55,8 @@ public class MinerAndroid extends ProgrammableAndroid { private final ItemSetting applyOptimizations = new ItemSetting<>(this, "reduced-block-updates", true); @ParametersAreNonnullByDefault - public MinerAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public MinerAndroid( + ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, tier, item, recipeType, recipe); addItemSetting(firesEvent, applyOptimizations); @@ -75,7 +74,8 @@ protected void dig(Block b, BlockMenu menu, Block block) { Collection drops = block.getDrops(effectivePickaxe); if (!SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(block.getType()) && !drops.isEmpty()) { - OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); + OfflinePlayer owner = + Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); if (Slimefun.getProtectionManager().hasPermission(owner, block.getLocation(), Interaction.BREAK_BLOCK)) { AndroidMineEvent event = new AndroidMineEvent(block, new AndroidInstance(this, b)); @@ -99,7 +99,8 @@ protected void moveAndDig(Block b, BlockMenu menu, BlockFace face, Block block) Collection drops = block.getDrops(effectivePickaxe); if (!SlimefunTag.UNBREAKABLE_MATERIALS.isTagged(block.getType()) && !drops.isEmpty()) { - OfflinePlayer owner = Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); + OfflinePlayer owner = + Bukkit.getOfflinePlayer(UUID.fromString(StorageCacheUtils.getData(b.getLocation(), "owner"))); if (Slimefun.getProtectionManager().hasPermission(owner, block.getLocation(), Interaction.BREAK_BLOCK)) { AndroidMineEvent event = new AndroidMineEvent(block, new AndroidInstance(this, b)); @@ -154,7 +155,17 @@ private void breakBlock(BlockMenu menu, Collection drops, Block block // "poof" a "new" block was generated SoundEffect.MINER_ANDROID_BLOCK_GENERATION_SOUND.playAt(block); - block.getWorld().spawnParticle(Particle.SMOKE_NORMAL, block.getX() + 0.5, block.getY() + 1.25, block.getZ() + 0.5, 8, 0.5, 0.5, 0.5, 0.015); + block.getWorld() + .spawnParticle( + Particle.SMOKE_NORMAL, + block.getX() + 0.5, + block.getY() + 1.25, + block.getZ() + 0.5, + 8, + 0.5, + 0.5, + 0.5, + 0.015); } else { block.setType(Material.AIR); } @@ -162,5 +173,4 @@ private void breakBlock(BlockMenu menu, Collection drops, Block block block.setType(Material.AIR); } } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index b6e966f85d..9b4fb1c1f0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -26,6 +26,15 @@ import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import io.papermc.lib.PaperLib; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Optional; +import java.util.UUID; +import java.util.function.Predicate; +import java.util.logging.Level; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenuClickHandler; import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; @@ -41,7 +50,6 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.OfflinePlayer; -import org.bukkit.Sound; import org.bukkit.Tag; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -57,20 +65,13 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Optional; -import java.util.UUID; -import java.util.function.Predicate; -import java.util.logging.Level; - public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, RecipeDisplayItem { - private static final List POSSIBLE_ROTATIONS = Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST); - private static final int[] BORDER = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 24, 25, 26, 27, 33, 35, 36, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53}; + private static final List POSSIBLE_ROTATIONS = + Arrays.asList(BlockFace.NORTH, BlockFace.EAST, BlockFace.SOUTH, BlockFace.WEST); + private static final int[] BORDER = { + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 24, 25, 26, 27, 33, 35, 36, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 + }; private static final int[] OUTPUT_BORDER = {10, 11, 12, 13, 14, 19, 23, 28, 32, 37, 38, 39, 40, 41}; private static final String DEFAULT_SCRIPT = "START-TURN_LEFT-REPEAT"; private static final int MAX_SCRIPT_LENGTH = 54; @@ -80,7 +81,8 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, private final int tier; @ParametersAreNonnullByDefault - public ProgrammableAndroid(ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { + public ProgrammableAndroid( + ItemGroup itemGroup, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { super(itemGroup, item, recipeType, recipe); this.tier = tier; @@ -96,7 +98,8 @@ public void init() { @Override public boolean canOpen(Block b, Player p) { - boolean isOwner = p.getUniqueId().toString().equals(StorageCacheUtils.getData(b.getLocation(), "owner")) || p.hasPermission("slimefun.android.bypass"); + boolean isOwner = p.getUniqueId().toString().equals(StorageCacheUtils.getData(b.getLocation(), "owner")) + || p.hasPermission("slimefun.android.bypass"); if (isOwner || AndroidShareMenu.isTrustedUser(b, p.getUniqueId())) { return true; @@ -108,7 +111,8 @@ public boolean canOpen(Block b, Player p) { @Override public void newInstance(BlockMenu menu, Block b) { - menu.replaceExistingItem(15, new CustomItemStack(HeadTexture.SCRIPT_START.getAsItemStack(), "&a启动/继续运行")); + menu.replaceExistingItem( + 15, new CustomItemStack(HeadTexture.SCRIPT_START.getAsItemStack(), "&a启动/继续运行")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { Slimefun.getLocalization().sendMessage(p, "android.started", true); StorageCacheUtils.setData(b.getLocation(), "paused", "false"); @@ -123,7 +127,10 @@ public void newInstance(BlockMenu menu, Block b) { return false; }); - menu.replaceExistingItem(16, new CustomItemStack(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&b内存核心", "", "&8\u21E8 &7单击打开脚本编辑器")); + menu.replaceExistingItem( + 16, + new CustomItemStack( + HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&b内存核心", "", "&8\u21E8 &7单击打开脚本编辑器")); menu.addMenuClickHandler(16, (p, slot, item, action) -> { StorageCacheUtils.setData(b.getLocation(), "paused", "true"); Slimefun.getLocalization().sendMessage(p, "android.stopped", true); @@ -131,7 +138,13 @@ public void newInstance(BlockMenu menu, Block b) { return false; }); - menu.replaceExistingItem(25, new CustomItemStack(HeadTexture.MOTOR.getAsItemStack(), Slimefun.getLocalization().getMessage("android.access-manager.title"), "", Slimefun.getLocalization().getMessage("android.access-manager.subtitle"))); + menu.replaceExistingItem( + 25, + new CustomItemStack( + HeadTexture.MOTOR.getAsItemStack(), + Slimefun.getLocalization().getMessage("android.access-manager.title"), + "", + Slimefun.getLocalization().getMessage("android.access-manager.subtitle"))); menu.addMenuClickHandler(25, (p, slot, item, action) -> { StorageCacheUtils.setData(b.getLocation(), "paused", "true"); Slimefun.getLocalization().sendMessage(p, "android.stopped", true); @@ -185,7 +198,8 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro var blockData = StorageCacheUtils.getBlock(b.getLocation()); String owner = blockData.getData("owner"); - if (!e.getPlayer().hasPermission("slimefun.android.bypass") && !e.getPlayer().getUniqueId().toString().equals(owner)) { + if (!e.getPlayer().hasPermission("slimefun.android.bypass") + && !e.getPlayer().getUniqueId().toString().equals(owner)) { // The Player is not allowed to break this android e.setCancelled(true); return; @@ -203,7 +217,7 @@ public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List dro /** * This returns the {@link AndroidType} that is associated with this {@link ProgrammableAndroid}. - * + * * @return The type of this {@link ProgrammableAndroid} */ public AndroidType getAndroidType() { @@ -213,7 +227,7 @@ public AndroidType getAndroidType() { /** * This returns the {@link AndroidFuelSource} for this {@link ProgrammableAndroid}. * It determines what kind of fuel is required to run it. - * + * * @return The required type of fuel */ public AndroidFuelSource getFuelSource() { @@ -221,7 +235,8 @@ public AndroidFuelSource getFuelSource() { case 1 -> AndroidFuelSource.SOLID; case 2 -> AndroidFuelSource.LIQUID; case 3 -> AndroidFuelSource.NUCLEAR; - default -> throw new IllegalStateException("Cannot convert the following Android tier to a fuel type: " + getTier()); + default -> throw new IllegalStateException( + "Cannot convert the following Android tier to a fuel type: " + getTier()); }; } @@ -247,10 +262,17 @@ public boolean isSynchronized() { @ParametersAreNonnullByDefault public void openScript(Player p, Block b, String sourceCode) { - ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); + ChestMenu menu = + new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); menu.setEmptySlotsClickable(false); - menu.addItem(0, new CustomItemStack(Instruction.START.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.START"), "", "&7\u21E8 &e左键 &7返回机器人的控制面板")); + menu.addItem( + 0, + new CustomItemStack( + Instruction.START.getItem(), + Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.START"), + "", + "&7\u21E8 &e左键 &7返回机器人的控制面板")); menu.addMenuClickHandler(0, (pl, slot, item, action) -> { BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation()); // Fixes #2937 @@ -279,7 +301,13 @@ public void openScript(Player p, Block b, String sourceCode) { } int slot = i + (hasFreeSlot ? 1 : 0); - menu.addItem(slot, new CustomItemStack(Instruction.REPEAT.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), "", "&7\u21E8 &e左键 &7返回机器人的控制面板")); + menu.addItem( + slot, + new CustomItemStack( + Instruction.REPEAT.getItem(), + Slimefun.getLocalization().getMessage(p, "android.scripts.instructions.REPEAT"), + "", + "&7\u21E8 &e左键 &7返回机器人的控制面板")); menu.addMenuClickHandler(slot, (pl, s, item, action) -> { BlockMenu inv = StorageCacheUtils.getMenu(b.getLocation()); // Fixes #2937 @@ -294,12 +322,30 @@ public void openScript(Player p, Block b, String sourceCode) { Instruction instruction = Instruction.getInstruction(script[i]); if (instruction == null) { - Slimefun.instance().getLogger().log(Level.WARNING, "Failed to parse Android instruction: {0}, maybe your server is out of date?", script[i]); + Slimefun.instance() + .getLogger() + .log( + Level.WARNING, + "Failed to parse Android instruction: {0}, maybe your server is out of date?", + script[i]); return; } ItemStack stack = instruction.getItem(); - menu.addItem(i, new CustomItemStack(stack, Slimefun.getLocalization().getMessage(p, "android.scripts.instructions." + Instruction.valueOf(script[i]).name()), "", "&7\u21E8 &e左键 &7编辑", "&7\u21E8 &e右键 &7删除", "&7\u21E8 &eShift + 右键 &7复制")); + menu.addItem( + i, + new CustomItemStack( + stack, + Slimefun.getLocalization() + .getMessage( + p, + "android.scripts.instructions." + + Instruction.valueOf(script[i]) + .name()), + "", + "&7\u21E8 &e左键 &7编辑", + "&7\u21E8 &e右键 &7删除", + "&7\u21E8 &eShift + 右键 &7复制")); menu.addMenuClickHandler(i, (pl, slot, item, action) -> { if (action.isRightClicked() && action.isShiftClicked()) { if (script.length == 54) { @@ -406,7 +452,10 @@ protected void openScriptDownloader(Player p, Block b, int page) { return false; }); - menu.addItem(48, new CustomItemStack(HeadTexture.SCRIPT_UP.getAsItemStack(), "&e上传脚本", "", "&6单击 &7将你正在用的脚本", "&7上传到服务器")); + menu.addItem( + 48, + new CustomItemStack( + HeadTexture.SCRIPT_UP.getAsItemStack(), "&e上传脚本", "", "&6单击 &7将你正在用的脚本", "&7上传到服务器")); menu.addMenuClickHandler(48, (pl, slot, item, action) -> { uploadScript(pl, b, page); return false; @@ -457,7 +506,11 @@ protected void openScriptDownloader(Player p, Block b, int page) { openScriptEditor(player, b); } } catch (Exception x) { - Slimefun.logger().log(Level.SEVERE, "An Exception was thrown when a User tried to download a Script!", x); + Slimefun.logger() + .log( + Level.SEVERE, + "An Exception was thrown when a User tried to download a Script!", + x); } return false; @@ -498,7 +551,8 @@ private void uploadScript(Player p, Block b, int page) { } public void openScriptEditor(Player p, Block b) { - ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); + ChestMenu menu = + new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); menu.setEmptySlotsClickable(false); menu.addItem(1, new CustomItemStack(HeadTexture.SCRIPT_FORWARD.getAsItemStack(), "&2> 编辑脚本", "", "&a修改你现有的脚本")); @@ -518,13 +572,23 @@ public void openScriptEditor(Player p, Block b) { return false; }); - menu.addItem(3, new CustomItemStack(HeadTexture.SCRIPT_NEW.getAsItemStack(), "&4> 创建新脚本", "", "&c删除你正在使用的脚本", "&c并创建一个全新的空白脚本")); + menu.addItem( + 3, + new CustomItemStack( + HeadTexture.SCRIPT_NEW.getAsItemStack(), "&4> 创建新脚本", "", "&c删除你正在使用的脚本", "&c并创建一个全新的空白脚本")); menu.addMenuClickHandler(3, (pl, slot, item, action) -> { openScript(pl, b, DEFAULT_SCRIPT); return false; }); - menu.addItem(5, new CustomItemStack(HeadTexture.SCRIPT_DOWN.getAsItemStack(), "&6> 下载脚本", "", "&e从服务器中下载其他玩家上传的脚本", "&e可以即下即用, 或者修改之后再使用")); + menu.addItem( + 5, + new CustomItemStack( + HeadTexture.SCRIPT_DOWN.getAsItemStack(), + "&6> 下载脚本", + "", + "&e从服务器中下载其他玩家上传的脚本", + "&e可以即下即用, 或者修改之后再使用")); menu.addMenuClickHandler(5, (pl, slot, item, action) -> { openScriptDownloader(pl, b, 1); return false; @@ -563,25 +627,35 @@ protected List getValidScriptInstructions() { } protected void editInstruction(Player p, Block b, String[] script, int index) { - ChestMenu menu = new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); + ChestMenu menu = + new ChestMenu(ChatColor.DARK_AQUA + Slimefun.getLocalization().getMessage(p, "android.scripts.editor")); ChestMenuUtils.drawBackground(menu, 0, 1, 2, 3, 4, 5, 6, 7, 8); menu.setEmptySlotsClickable(false); - menu.addItem(9, new CustomItemStack(HeadTexture.SCRIPT_PAUSE.getAsItemStack(), "&f什么也不做"), (pl, slot, item, action) -> { - String code = deleteInstruction(script, index); - setScript(b.getLocation(), code); - openScript(p, b, code); - return false; - }); + menu.addItem( + 9, + new CustomItemStack(HeadTexture.SCRIPT_PAUSE.getAsItemStack(), "&f什么也不做"), + (pl, slot, item, action) -> { + String code = deleteInstruction(script, index); + setScript(b.getLocation(), code); + openScript(p, b, code); + return false; + }); int i = 10; for (Instruction instruction : getValidScriptInstructions()) { - menu.addItem(i, new CustomItemStack(instruction.getItem(), Slimefun.getLocalization().getMessage(p, "android.scripts.instructions." + instruction.name())), (pl, slot, item, action) -> { - String code = addInstruction(script, index, instruction); - setScript(b.getLocation(), code); - openScript(p, b, code); - return false; - }); + menu.addItem( + i, + new CustomItemStack( + instruction.getItem(), + Slimefun.getLocalization() + .getMessage(p, "android.scripts.instructions." + instruction.name())), + (pl, slot, item, action) -> { + String code = addInstruction(script, index, instruction); + setScript(b.getLocation(), code); + openScript(p, b, code); + return false; + }); i++; } @@ -601,7 +675,9 @@ public void setScript(@Nonnull Location l, @Nonnull String script) { Validate.notNull(script, "No script given"); Validate.isTrue(script.startsWith(Instruction.START.name() + '-'), "A script must begin with a 'START' token."); Validate.isTrue(script.endsWith('-' + Instruction.REPEAT.name()), "A script must end with a 'REPEAT' token."); - Validate.isTrue(CommonPatterns.DASH.split(script).length <= MAX_SCRIPT_LENGTH, "Scripts may not have more than " + MAX_SCRIPT_LENGTH + " segments"); + Validate.isTrue( + CommonPatterns.DASH.split(script).length <= MAX_SCRIPT_LENGTH, + "Scripts may not have more than " + MAX_SCRIPT_LENGTH + " segments"); StorageCacheUtils.setData(l, "script", script); } @@ -677,7 +753,7 @@ public int[] getInputSlots() { @Override public int[] getOutputSlots() { - return new int[] { 20, 21, 22, 29, 30, 31 }; + return new int[] {20, 21, 22, 29, 30, 31}; } public int getTier() { @@ -713,7 +789,12 @@ protected void tick(Block b, SlimefunBlockData data) { Instruction instruction = Instruction.getInstruction(script[index]); if (instruction == null) { - Slimefun.instance().getLogger().log(Level.WARNING, "Failed to parse Android instruction: {0}, maybe your server is out of date?", script[index]); + Slimefun.instance() + .getLogger() + .log( + Level.WARNING, + "Failed to parse Android instruction: {0}, maybe your server is out of date?", + script[index]); return; } @@ -723,7 +804,8 @@ protected void tick(Block b, SlimefunBlockData data) { } @ParametersAreNonnullByDefault - private void executeInstruction(Instruction instruction, Block b, BlockMenu inv, SlimefunBlockData data, int index) { + private void executeInstruction( + Instruction instruction, Block b, BlockMenu inv, SlimefunBlockData data, int index) { if (getAndroidType().isType(instruction.getRequiredType())) { String rotationData = data.getData("rotation"); BlockFace face = rotationData == null ? BlockFace.NORTH : BlockFace.valueOf(rotationData); @@ -773,7 +855,8 @@ protected void rotate(Block b, BlockFace current, int mod) { } protected void depositItems(BlockMenu menu, Block facedBlock) { - if (facedBlock.getType() == Material.DISPENSER && StorageCacheUtils.isBlock(facedBlock.getLocation(), "ANDROID_INTERFACE_ITEMS")) { + if (facedBlock.getType() == Material.DISPENSER + && StorageCacheUtils.isBlock(facedBlock.getLocation(), "ANDROID_INTERFACE_ITEMS")) { BlockState state = PaperLib.getBlockState(facedBlock, false).getState(); if (state instanceof Dispenser dispenser) { @@ -781,7 +864,8 @@ protected void depositItems(BlockMenu menu, Block facedBlock) { ItemStack stack = menu.getItemInSlot(slot); if (stack != null) { - Optional optional = dispenser.getInventory().addItem(stack).values().stream().findFirst(); + Optional optional = dispenser.getInventory().addItem(stack).values().stream() + .findFirst(); if (optional.isPresent()) { menu.replaceExistingItem(slot, optional.get()); @@ -795,7 +879,8 @@ protected void depositItems(BlockMenu menu, Block facedBlock) { } protected void refuel(BlockMenu menu, Block facedBlock) { - if (facedBlock.getType() == Material.DISPENSER && StorageCacheUtils.isBlock(facedBlock.getLocation(), "ANDROID_INTERFACE_FUEL")) { + if (facedBlock.getType() == Material.DISPENSER + && StorageCacheUtils.isBlock(facedBlock.getLocation(), "ANDROID_INTERFACE_FUEL")) { BlockState state = PaperLib.getBlockState(facedBlock, false).getState(); if (state instanceof Dispenser dispenser) { @@ -810,7 +895,8 @@ protected void refuel(BlockMenu menu, Block facedBlock) { } } - private boolean insertFuel(BlockMenu menu, Inventory dispenser, int slot, ItemStack currentFuel, ItemStack newFuel) { + private boolean insertFuel( + BlockMenu menu, Inventory dispenser, int slot, ItemStack currentFuel, ItemStack newFuel) { if (currentFuel == null) { menu.replaceExistingItem(43, newFuel); dispenser.setItem(slot, null); @@ -864,7 +950,8 @@ public boolean onClick(Player p, int slot, ItemStack cursor, ClickAction action) } @Override - public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { + public boolean onClick( + InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { return cursor == null || cursor.getType() == null || cursor.getType() == Material.AIR; } }); @@ -895,7 +982,9 @@ protected void move(Block b, BlockFace face, Block block) { return; } - if (block.getY() > block.getWorld().getMinHeight() && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) { + if (block.getY() > block.getWorld().getMinHeight() + && block.getY() < block.getWorld().getMaxHeight() + && block.isEmpty()) { if (!block.getWorld().getWorldBorder().isInside(block.getLocation())) { return; @@ -944,5 +1033,4 @@ protected boolean chopTree(Block b, BlockMenu menu, BlockFace face) { protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) { throw new UnsupportedOperationException("Non-farming Android tried to farm!"); } - } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java index 7f50082beb..7ff990e48c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java @@ -1,5 +1,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids; +import io.github.bakedlibs.dough.config.Config; +import io.github.bakedlibs.dough.items.CustomItemStack; +import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; +import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; +import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -8,10 +13,8 @@ import java.util.List; import java.util.UUID; import java.util.logging.Level; - import javax.annotation.Nonnull; import javax.annotation.ParametersAreNonnullByDefault; - import org.apache.commons.lang.Validate; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -19,15 +22,9 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import io.github.bakedlibs.dough.config.Config; -import io.github.bakedlibs.dough.items.CustomItemStack; -import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; -import io.github.thebusybiscuit.slimefun4.utils.ChatUtils; -import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; - /** * A {@link Script} represents runnable code for a {@link ProgrammableAndroid}. - * + * * @author TheBusyBiscuit * */ @@ -40,7 +37,7 @@ public final class Script { /** * This constructs a new {@link Script} from the given {@link Config}. - * + * * @param config * The {@link Config} */ @@ -64,7 +61,7 @@ private Script(@Nonnull Config config) { /** * This returns the name of this {@link Script}. - * + * * @return The name */ @Nonnull @@ -75,7 +72,7 @@ public String getName() { /** * This returns the author of this {@link Script}. * The author is the person who initially created and uploaded this {@link Script}. - * + * * @return The author of this {@link Script} */ @Nonnull @@ -87,7 +84,7 @@ public String getAuthor() { * This method returns the actual code of this {@link Script}. * It is basically a {@link String} describing the order of {@link Instruction Instructions} that * shall be executed. - * + * * @return The code for this {@link Script} */ @Nonnull @@ -98,10 +95,10 @@ public String getSourceCode() { /** * This method determines whether the given {@link OfflinePlayer} is the author of * this {@link Script}. - * + * * @param p * The {@link OfflinePlayer} to check for - * + * * @return Whether the given {@link OfflinePlayer} is the author of this {@link Script}. */ public boolean isAuthor(@Nonnull OfflinePlayer p) { @@ -111,10 +108,10 @@ public boolean isAuthor(@Nonnull OfflinePlayer p) { /** * This method checks whether a given {@link Player} is able to leave a rating for this {@link Script}. * A {@link Player} is unable to rate his own {@link Script} or a {@link Script} he already rated before. - * + * * @param p * The {@link Player} to check for - * + * * @return Whether the given {@link Player} is able to rate this {@link Script} */ public boolean canRate(@Nonnull Player p) { @@ -124,7 +121,8 @@ public boolean canRate(@Nonnull Player p) { List upvoters = config.getStringList("rating.positive"); List downvoters = config.getStringList("rating.negative"); - return !upvoters.contains(p.getUniqueId().toString()) && !downvoters.contains(p.getUniqueId().toString()); + return !upvoters.contains(p.getUniqueId().toString()) + && !downvoters.contains(p.getUniqueId().toString()); } @Nonnull @@ -156,7 +154,7 @@ private String getScriptRatingPercentage() { /** * This method returns the amount of upvotes this {@link Script} has received. - * + * * @return The amount of upvotes */ public int getUpvotes() { @@ -165,7 +163,7 @@ public int getUpvotes() { /** * This method returns the amount of downvotes this {@link Script} has received. - * + * * @return The amount of downvotes */ public int getDownvotes() { @@ -174,7 +172,7 @@ public int getDownvotes() { /** * This returns how often this {@link Script} has been downloaded. - * + * * @return The amount of downloads for this {@link Script}. */ public int getDownloads() { @@ -184,7 +182,7 @@ public int getDownloads() { /** * This returns the "rating" of this {@link Script}. * This value is calculated from the up- and downvotes this {@link Script} received. - * + * * @return The rating for this {@link Script} */ public float getRating() { @@ -244,7 +242,13 @@ private static void loadScripts(@Nonnull List