From ce18519808559201103c3e43b1753c877fe2002d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Wed, 29 Jul 2020 23:21:41 +0200 Subject: [PATCH 01/26] Re-added conditional github warning messages --- .../core/services/github/GitHubConnector.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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 f168dc322..cdf77ef0c 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 @@ -54,7 +54,18 @@ abstract class GitHubConnector { writeCacheFile(resp.getBody()); } else { - Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] {repository + getURLSuffix(), resp.getStatus(), resp.getBody()}); + if (github.isLoggingEnabled()) { + Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] {repository + getURLSuffix(), resp.getStatus(), resp.getBody()}); + } + + // It has the cached file, let's just read that then + if (file.exists()) { + JsonNode cache = readCacheFile(); + + if (cache != null) { + onSuccess(cache); + } + } } } catch (UnirestException e) { From 0412a2aec1a13e64ac53c2a34885723f9ea61d3b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 10:23:44 +0200 Subject: [PATCH 02/26] Fixes #2151 --- CHANGELOG.md | 1 + .../slimefun4/core/services/MetricsService.java | 2 +- .../implementation/items/multiblocks/OreWasher.java | 12 ++++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4d8ab3dc..a675134df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -57,6 +57,7 @@ * Fixed Metrics not updating automatically * Fixed #2143 * Fixed #2145 +* Fixed #2151 ## Release Candidate 14 (12 Jul 2020) 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 d60f0961f..9b00e302c 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 @@ -175,7 +175,7 @@ public class MetricsService { return node.getObject().getInt("tag_name"); } catch (UnirestException e) { - plugin.getLogger().log(Level.SEVERE, "Failed to fetch latest builds for SFMetrics"); + plugin.getLogger().log(Level.WARNING, "Failed to fetch latest builds for Metrics: {0}", e.getMessage()); return -1; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java index 73e2a4fe3..099ab6f04 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java @@ -34,6 +34,18 @@ public class OreWasher extends MultiBlockMachine { legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer"); dusts = new ItemStack[] { SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.TIN_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST }; } + + @Override + protected void registerDefaultRecipes(List recipes) { + // Iron and Gold are displayed as Ore Crusher recipes, as that is their primary + // way of obtainining them. But we also wanna display them here, so we just + // add these two recipes manually + recipes.add(SlimefunItems.SIFTED_ORE); + recipes.add(SlimefunItems.IRON_DUST); + + recipes.add(SlimefunItems.SIFTED_ORE); + recipes.add(SlimefunItems.GOLD_DUST); + } @Override public List getDisplayRecipes() { From 77131d8bdbe0a16858be01336476f2e21d1f29c3 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 11:36:41 +0200 Subject: [PATCH 03/26] [CI skip] Locked release data for RC 15 --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a675134df..5e1d6caf1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ **Table of contents** -- [Release Candidate 15 (TBD)](#release-candidate-15-tbd) +- [Release Candidate 15 (01 Aug 2020)](#release-candidate-15-01-aug-2020) - [Release Candidate 14 (12 Jul 2020)](#release-candidate-14-12-jul-2020) - [Release Candidate 13 (16 Jun 2020)](#release-candidate-13-16-jun-2020) - [Release Candidate 12 (27 May 2020)](#release-candidate-12-27-may-2020) @@ -20,7 +20,7 @@ -## Release Candidate 15 (TBD) +## Release Candidate 15 (01 Aug 2020) #### Additions * Added "Bone Block -> Bone meal" recipe to the Grind Stone From e61368051337d602e36b7277147cdde1ccf4a3a8 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:11:13 +0200 Subject: [PATCH 04/26] [CI skip] Added YAML Linter --- .github/workflows/yaml-linter.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/yaml-linter.yml diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml new file mode 100644 index 000000000..4d301f766 --- /dev/null +++ b/.github/workflows/yaml-linter.yml @@ -0,0 +1,22 @@ +name: YAML Linter + +on: + push: + paths: + - '*.yml' + pull_request: + branches: + - master + paths: + - '*.yml' + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v1 + - name: YAML Linter + uses: ibiqlik/action-yamllint@v1.0.0 From 8c942eecc39c4f7a14bde5e1b20331b3e3b3f1ee Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:13:04 +0200 Subject: [PATCH 05/26] [CI skip] Implemented YAML Linter action --- .github/workflows/yaml-linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml index 4d301f766..8f24fee2b 100644 --- a/.github/workflows/yaml-linter.yml +++ b/.github/workflows/yaml-linter.yml @@ -3,12 +3,12 @@ name: YAML Linter on: push: paths: - - '*.yml' + - '**.yml' pull_request: branches: - master paths: - - '*.yml' + - '**.yml' jobs: build: From 63fddd46fa973d78472e52d04fcb8d3756360b31 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:18:10 +0200 Subject: [PATCH 06/26] [CI skip] Added YAMl Linter config file --- .github/yaml-lint.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 .github/yaml-lint.yml diff --git a/.github/yaml-lint.yml b/.github/yaml-lint.yml new file mode 100644 index 000000000..bc749542f --- /dev/null +++ b/.github/yaml-lint.yml @@ -0,0 +1,12 @@ +extends: default +locale: en_US.UTF-8 + +yaml-files: +- '*.yml' + +rules: + line-length: + max: 160 + level: warning + + indentation: disable From ec7299bba21eb3a9bdef50293e45b7c50a2e573d Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:19:17 +0200 Subject: [PATCH 07/26] [CI skip] YAMl linter should now use the config --- .github/workflows/yaml-linter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/yaml-linter.yml b/.github/workflows/yaml-linter.yml index 8f24fee2b..ca7054f6a 100644 --- a/.github/workflows/yaml-linter.yml +++ b/.github/workflows/yaml-linter.yml @@ -20,3 +20,5 @@ jobs: uses: actions/checkout@v1 - name: YAML Linter uses: ibiqlik/action-yamllint@v1.0.0 + with: + config_file: '.github/yaml-lint.yml' From 593da85d4414fcfd0dfb4ce4418a25d244ff1bba Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:22:59 +0200 Subject: [PATCH 08/26] [CI skip] Updated yaml-linter config --- .github/yaml-lint.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/yaml-lint.yml b/.github/yaml-lint.yml index bc749542f..45cf67848 100644 --- a/.github/yaml-lint.yml +++ b/.github/yaml-lint.yml @@ -9,4 +9,9 @@ rules: max: 160 level: warning + ## We don't need indentation warnings indentation: disable + + trailing-spaces: + ignore: | + /src/main/resources/languages/*.yml From a363cd1f5f1f6959fadab1b837765d929b79125b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:24:56 +0200 Subject: [PATCH 09/26] [CI skip] Removed trailing-spaces from config --- src/main/resources/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 9e787a99b..7c21f2dd8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,7 +3,7 @@ options: # These builds are much more tested and are far less likely to have any issues. # Note: When running a stable build auto-updates ONLY update to other stable builds! Perfect eh? # You can download the latest stable build here: https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/ - + auto-update: true backwards-compatibility: true chat-prefix: '&a&lSlimefun 4&7> ' @@ -17,12 +17,12 @@ options: language: en enable-translations: true log-duplicate-block-entries: true - + guide: default-view-book: false show-vanilla-recipes: true receive-on-first-join: true - + researches: free-in-creative-mode: true enable-fireworks: true From 771456b6cde90a3a9afbea7e13a6ce59afc50adb Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:30:20 +0200 Subject: [PATCH 10/26] [CI skip] Fixed some malformed yaml --- .github/workflows/close-invalid-issues.yml | 6 +++--- .github/workflows/closed-issues-reason.yml | 11 ++++++----- .github/workflows/duplicates.yml | 4 ++-- .github/workflows/translator-webhook.yml | 9 +++++---- .github/workflows/update-changelog.yml | 6 +++--- src/main/resources/languages/categories_en.yml | 2 +- src/main/resources/languages/researches_en.yml | 2 +- src/main/resources/languages/resources_en.yml | 2 +- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/close-invalid-issues.yml b/.github/workflows/close-invalid-issues.yml index 248850e63..21683f43a 100644 --- a/.github/workflows/close-invalid-issues.yml +++ b/.github/workflows/close-invalid-issues.yml @@ -1,7 +1,7 @@ name: Close invalid Issue -on: - issues: +on: + issues: types: [opened] jobs: @@ -29,6 +29,6 @@ jobs: body: |- Your issue seems to be missing our template. [Click here to create a bug report](https://github.com/TheBusyBiscuit/Slimefun4/issues/new/choose) - +
Please remember that this Bug Tracker is exclusively reserved for Bug reports, any other form of discussion, like suggestions or questions should be posted on our discord server (You can find a link [on our main page](https://github.com/TheBusyBiscuit/Slimefun4#discord)). diff --git a/.github/workflows/closed-issues-reason.yml b/.github/workflows/closed-issues-reason.yml index c9212540d..75a31fa19 100644 --- a/.github/workflows/closed-issues-reason.yml +++ b/.github/workflows/closed-issues-reason.yml @@ -1,6 +1,7 @@ name: Respond to closed Issue -on: - issues: + +on: + issues: types: [closed] jobs: @@ -30,10 +31,10 @@ jobs: body: |- Your issue was closed, it may fall under one or more of the following categories. **Please wait for an admin to tick off the points that apply.** - +
Please respond below, if you have any questions. Do **not** open a new Issue unless explicitly told otherwise, comment below or edit your post instead. - +
* [ ] You did not follow our template. Please follow the Issue template to help us identify your issue more effectively. * [ ] You did not provide any information about your versions (We absolutely need the exact version numbers that are installed on your Server, \"latest\" is not helpful) * [ ] You did not provide a proper description to the problem. Try to write at least 4-6 sentences on how to reproduce this. @@ -50,5 +51,5 @@ jobs: * [ ] You are using an unsupported version of Minecraft. We only provide support for the Minecraft versions Slimefun was developed for, older versions are not supported anymore. * [ ] You are using a \"stable\" version of Slimefun (prefixed with \"RC - \"), your issue may have been fixed in a development build, so we only accept bug reports from those. * [ ] You are on the wrong issue tracker. We would like to remind you that this Issue Tracker is **only for Slimefun**. To report bugs on any addons, head to the corresponding issue tracker of that addon. - +
Make sure to check out our article on [How to report bugs](https://github.com/TheBusyBiscuit/Slimefun4/wiki/How-to-report-bugs) for even more information. diff --git a/.github/workflows/duplicates.yml b/.github/workflows/duplicates.yml index 99f4ebc26..3cdafa89a 100644 --- a/.github/workflows/duplicates.yml +++ b/.github/workflows/duplicates.yml @@ -1,7 +1,7 @@ name: Mark Issue as duplicate -on: - issue_comment: +on: + issue_comment: types: [created] jobs: diff --git a/.github/workflows/translator-webhook.yml b/.github/workflows/translator-webhook.yml index 0f5118b52..03f276aba 100644 --- a/.github/workflows/translator-webhook.yml +++ b/.github/workflows/translator-webhook.yml @@ -1,18 +1,19 @@ name: Translation Notifier -on: + +on: push: branches: - master paths: - 'src/main/resources/languages/**_en.yml' - + jobs: notify: - + name: Translation-Notifier runs-on: ubuntu-latest if: github.repository == 'TheBusyBiscuit/Slimefun4' - + steps: - name: Discord Notification uses: Ilshidur/action-discord@master diff --git a/.github/workflows/update-changelog.yml b/.github/workflows/update-changelog.yml index 9d18c206a..38e1780e4 100644 --- a/.github/workflows/update-changelog.yml +++ b/.github/workflows/update-changelog.yml @@ -1,19 +1,19 @@ name: Changelog Populator -on: +on: push: branches: - master paths: - 'CHANGELOG.md' - + jobs: populate: name: Changelog Generator runs-on: ubuntu-latest if: github.repository == 'TheBusyBiscuit/Slimefun4' - + steps: - name: TOC Generator uses: technote-space/toc-generator@v2.4.0 diff --git a/src/main/resources/languages/categories_en.yml b/src/main/resources/languages/categories_en.yml index 5b660c4c0..091a89b7e 100644 --- a/src/main/resources/languages/categories_en.yml +++ b/src/main/resources/languages/categories_en.yml @@ -22,4 +22,4 @@ slimefun: valentines_day: 'Valentine''s Day (14th February)' easter: 'Easter (April)' birthday: 'TheBusyBiscuit''s birthday (26th October)' - halloween: 'Halloween (31st October)' \ No newline at end of file + halloween: 'Halloween (31st October)' diff --git a/src/main/resources/languages/researches_en.yml b/src/main/resources/languages/researches_en.yml index baf9a3d33..0c9346183 100644 --- a/src/main/resources/languages/researches_en.yml +++ b/src/main/resources/languages/researches_en.yml @@ -238,4 +238,4 @@ slimefun: enchantment_rune: Ancient Enchanting lead_clothing: Lead Clothing tape_measure: Tape Measure - iron_golem_assembler: Automated Iron Golems \ No newline at end of file + iron_golem_assembler: Automated Iron Golems diff --git a/src/main/resources/languages/resources_en.yml b/src/main/resources/languages/resources_en.yml index c92c438e3..6d880c399 100644 --- a/src/main/resources/languages/resources_en.yml +++ b/src/main/resources/languages/resources_en.yml @@ -22,4 +22,4 @@ resources: lead_ore_chunk: 'Lead Ore Chunk' zinc_ore_chunk: 'Zinc Ore Chunk' nickel_ore_chunk: 'Nickel Ore Chunk' - cobalt_ore_chunk: 'Cobalt Ore Chunk' \ No newline at end of file + cobalt_ore_chunk: 'Cobalt Ore Chunk' From a6a93e73c521d54fdaad0d4557e4d80ab41aed27 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:31:53 +0200 Subject: [PATCH 11/26] [CI skip] Fixed YAML Linter config --- .github/yaml-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/yaml-lint.yml b/.github/yaml-lint.yml index 45cf67848..07a8c09fd 100644 --- a/.github/yaml-lint.yml +++ b/.github/yaml-lint.yml @@ -11,7 +11,7 @@ rules: ## We don't need indentation warnings indentation: disable - + trailing-spaces: ignore: | /src/main/resources/languages/*.yml From be216bec1f123ea03bbc76ad3c9ef234092f892b Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:34:24 +0200 Subject: [PATCH 12/26] [CI skip] Test? --- .github/workflows/closed-issues-reason.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/closed-issues-reason.yml b/.github/workflows/closed-issues-reason.yml index 75a31fa19..a131651fe 100644 --- a/.github/workflows/closed-issues-reason.yml +++ b/.github/workflows/closed-issues-reason.yml @@ -32,9 +32,10 @@ jobs: Your issue was closed, it may fall under one or more of the following categories. **Please wait for an admin to tick off the points that apply.**
+ Please respond below, if you have any questions. Do **not** open a new Issue unless explicitly told otherwise, comment below or edit your post instead. -
+ * [ ] You did not follow our template. Please follow the Issue template to help us identify your issue more effectively. * [ ] You did not provide any information about your versions (We absolutely need the exact version numbers that are installed on your Server, \"latest\" is not helpful) * [ ] You did not provide a proper description to the problem. Try to write at least 4-6 sentences on how to reproduce this. @@ -52,4 +53,5 @@ jobs: * [ ] You are using a \"stable\" version of Slimefun (prefixed with \"RC - \"), your issue may have been fixed in a development build, so we only accept bug reports from those. * [ ] You are on the wrong issue tracker. We would like to remind you that this Issue Tracker is **only for Slimefun**. To report bugs on any addons, head to the corresponding issue tracker of that addon.
+ Make sure to check out our article on [How to report bugs](https://github.com/TheBusyBiscuit/Slimefun4/wiki/How-to-report-bugs) for even more information. From 08a483c8989dfecd1a5f360e709347857bd742c5 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:38:02 +0200 Subject: [PATCH 13/26] [CI skip] Updated automated responses --- .github/workflows/closed-issues-reason.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/closed-issues-reason.yml b/.github/workflows/closed-issues-reason.yml index a131651fe..06546fdb1 100644 --- a/.github/workflows/closed-issues-reason.yml +++ b/.github/workflows/closed-issues-reason.yml @@ -29,21 +29,19 @@ jobs: token: ${{ secrets.ACCESS_TOKEN }} issue_number: ${{ github.event.issue.number }} body: |- - Your issue was closed, it may fall under one or more of the following categories. + Your issue has been closed by an admin, it may fall under one or more of the following categories. **Please wait for an admin to tick off the points that apply.**
- Please respond below, if you have any questions. - Do **not** open a new Issue unless explicitly told otherwise, comment below or edit your post instead. - * [ ] You did not follow our template. Please follow the Issue template to help us identify your issue more effectively. * [ ] You did not provide any information about your versions (We absolutely need the exact version numbers that are installed on your Server, \"latest\" is not helpful) - * [ ] You did not provide a proper description to the problem. Try to write at least 4-6 sentences on how to reproduce this. + * [ ] You did not provide a proper description to the problem. Try to write at least 4-6 sentences and/or provide screenshots or videos on how to reproduce this. * [ ] We were unable to reproduce issue, if you think your issue still persists then please comment down below and give a better description on how to reproduce it. * [ ] Your issue was posted in a foreign language, we only accept english issues on here. - * [ ] Your issue is not a bug, it is either intended or something we cannot change. + * [ ] Your issue is not a bug, it is intended to work this way. + * [ ] Your issue is not really a bug, it is a limitation or simply something we have no control over. * [ ] Your issue is not a bug, please only use this issue tracker to report bugs. Any other kind of communication should happen on discord. - * [ ] Your issue was already reported, it is a duplicate. Check the other issues first before posting! + * [ ] Your issue has already been reported before, it is a duplicate. Check the other issues first before posting! * [ ] You posted an error without using pastebin. Please always post errors via pastebin otherwise they become nearly unreadable. * [ ] You seem to be reporting multiple bugs at once. Please make a seperate issue for each bug you encountered, so we can properly handle them individually. * [ ] Your issue has already been fixed in a later version of Slimefun or CS-CoreLib, you should update. @@ -54,4 +52,6 @@ jobs: * [ ] You are on the wrong issue tracker. We would like to remind you that this Issue Tracker is **only for Slimefun**. To report bugs on any addons, head to the corresponding issue tracker of that addon.
+ Please respond below, if you have any further questions. + Do **not** open a new Issue unless explicitly told otherwise, comment below or edit your post instead.
Make sure to check out our article on [How to report bugs](https://github.com/TheBusyBiscuit/Slimefun4/wiki/How-to-report-bugs) for even more information. From 17abb120ca02870cccfaee1b28a3b63dabe3e7e7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 13:39:39 +0200 Subject: [PATCH 14/26] [CI skip] Fixed formatting --- .github/workflows/close-invalid-issues.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/close-invalid-issues.yml b/.github/workflows/close-invalid-issues.yml index 21683f43a..54b3bb834 100644 --- a/.github/workflows/close-invalid-issues.yml +++ b/.github/workflows/close-invalid-issues.yml @@ -29,6 +29,6 @@ jobs: body: |- Your issue seems to be missing our template. [Click here to create a bug report](https://github.com/TheBusyBiscuit/Slimefun4/issues/new/choose) -
+ Please remember that this Bug Tracker is exclusively reserved for Bug reports, any other form of discussion, like suggestions or questions should be posted on our discord server (You can find a link [on our main page](https://github.com/TheBusyBiscuit/Slimefun4#discord)). From 2999e777f9c32e937bf23faa993f551f72f05ec8 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Thu, 30 Jul 2020 11:45:09 +0000 Subject: [PATCH 15/26] Translate messages_ru.yml via GitLocalize --- src/main/resources/languages/messages_ru.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/resources/languages/messages_ru.yml b/src/main/resources/languages/messages_ru.yml index 44c6cb42c..5b163e04a 100644 --- a/src/main/resources/languages/messages_ru.yml +++ b/src/main/resources/languages/messages_ru.yml @@ -152,6 +152,15 @@ messages: - "&7Вы съели странное печенье, до жути напоминающее бисквит" - "&7Неоновые таблички просто ШИК!" piglin-barter: "&4Вы не можете торговать с пиглинами, используя Slimefun предметы" + enchantment-rune: + fail: "&cВы не можете зачаровать этот предмет." + no-enchantment: "&cНе удалось найти подходящее зачарование для этого предмета." + success: "&aВы успешно применили случайное зачарование к этому предмету." + tape-measure: + no-anchor: "&cВы должны установить якорь, прежде чем начать измерение!" + wrong-world: "&cВаш якорь находится в другом мире!" + distance: "&7Измерение завершено. &eРасстояние: %distance%" + anchor-set: "&aЯкорь успешно установлен:&e %anchor%" machines: pattern-not-found: "&eК сожалению, не удалось распознать этот рецепт. Пожалуйста, разложите предметы в верной последовательности в раздатчик." @@ -294,7 +303,6 @@ languages: el: Греческий he: Иврит pt: Португальский (Португалия) - pt-BR: Португальский (Бразилия) ar: Арабский af: Бурский da: Датский @@ -306,6 +314,7 @@ languages: fa: Персидский th: Тайский ro: Румынский + pt-BR: Португальский (Бразилия) bg: Болгарский ko: Корейский tr: Турецкий From d3f0839a0cd18345fd22eed1bcda6df08fa75f54 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 11:45:10 +0000 Subject: [PATCH 16/26] Translate messages_ru.yml via GitLocalize From 52a54c5ff1a4d782f3cd436fdc5da1d2951df7d3 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Thu, 30 Jul 2020 11:45:12 +0000 Subject: [PATCH 17/26] Translate recipes_ru.yml via GitLocalize From 8ddb055083fa81ef454833607734c7017da30681 Mon Sep 17 00:00:00 2001 From: SoSeDiK Date: Thu, 30 Jul 2020 11:45:13 +0000 Subject: [PATCH 18/26] Translate researches_ru.yml via GitLocalize --- src/main/resources/languages/researches_ru.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/resources/languages/researches_ru.yml b/src/main/resources/languages/researches_ru.yml index c73215fa2..ee494c173 100644 --- a/src/main/resources/languages/researches_ru.yml +++ b/src/main/resources/languages/researches_ru.yml @@ -236,3 +236,7 @@ slimefun: advanced_industrial_miner: Улучшенная добыча magical_zombie_pills: Дезомбификация auto_brewer: Промышленная пивоварня + enchantment_rune: Древнее зачарование + lead_clothing: Свинцовое обмундирование + tape_measure: Рулетка + iron_golem_assembler: Образователь железных големов From 2f05b9e4f877e62621c88f4e500b4256fc56b801 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Thu, 30 Jul 2020 17:20:21 +0200 Subject: [PATCH 19/26] Various fixes and performance improvements, mainly for talismans --- CHANGELOG.md | 7 +++ .../items/magical/talismans/Talisman.java | 31 ++++++---- .../slimefun4/utils/SlimefunUtils.java | 56 +++++++++++++------ 3 files changed, 66 insertions(+), 28 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e1d6caf1..27a1e0044 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,9 @@ * Optimized Cargo networks for Paper * Optimized Multiblocks for Paper * Optimized Enhanced Furnaces for Paper +* General performance improvements for Talismans +* General performance improvements for GPS Emergency Transmitters +* General performance improvements for Infused Magnets #### Fixes * Fixed Slimefun Armor sometimes not applying its effects @@ -58,6 +61,10 @@ * Fixed #2143 * Fixed #2145 * Fixed #2151 +* Fixed old Talismans not working +* Fixed Talismans sometimes not getting consumed properly +* Fixed old Infused Magnets not working +* Fixed old GPS Emergency Transmitters not working ## Release Candidate 14 (12 Jul 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java index e0a58a0da..2b824737c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java @@ -19,10 +19,12 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; +import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; import io.github.thebusybiscuit.slimefun4.core.researching.Research; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; @@ -150,9 +152,9 @@ public class Talisman extends SlimefunItem { ItemStack talismanItem = talisman.getItem(); - if (p.getInventory().containsAtLeast(talismanItem, 1)) { - if (Slimefun.hasUnlocked(p, talismanItem, true)) { - activateTalisman(e, p, p.getInventory(), talisman, talismanItem); + if (SlimefunUtils.containsSimilarItem(p.getInventory(), talismanItem, true)) { + if (Slimefun.hasUnlocked(p, talisman, true)) { + activateTalisman(e, p, p.getInventory(), talisman); return true; } else { @@ -162,9 +164,9 @@ public class Talisman extends SlimefunItem { else { ItemStack enderTalisman = talisman.getEnderVariant(); - if (p.getEnderChest().containsAtLeast(enderTalisman, 1)) { - if (Slimefun.hasUnlocked(p, enderTalisman, true)) { - activateTalisman(e, p, p.getEnderChest(), talisman, enderTalisman); + if (SlimefunUtils.containsSimilarItem(p.getEnderChest(), enderTalisman, true)) { + if (Slimefun.hasUnlocked(p, talisman, true)) { + activateTalisman(e, p, p.getEnderChest(), talisman); return true; } else { @@ -177,12 +179,11 @@ public class Talisman extends SlimefunItem { } } - private static void activateTalisman(Event e, Player p, Inventory inv, Talisman talisman, ItemStack talismanItem) { - consumeItem(inv, talisman, talismanItem); + private static void activateTalisman(Event e, Player p, Inventory inv, Talisman talisman) { + consumeItem(inv, talisman); applyTalismanEffects(p, talisman); cancelEvent(e, talisman); sendMessage(p, talisman); - } private static void applyTalismanEffects(Player p, Talisman talisman) { @@ -203,9 +204,17 @@ public class Talisman extends SlimefunItem { } } - private static void consumeItem(Inventory inv, Talisman talisman, ItemStack talismanItem) { + private static void consumeItem(Inventory inv, Talisman talisman) { if (talisman.isConsumable()) { - inv.removeItem(talismanItem); + ItemStack[] contents = inv.getContents(); + for (int i = 0; i < contents.length; i++) { + ItemStack item = contents[i]; + + if (SlimefunUtils.isItemSimilar(item, talisman.getItem(), true, false)) { + ItemUtils.consumeItem(item, false); + return; + } + } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index e73acbb3c..260c6b971 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -212,14 +212,16 @@ public final class SlimefunUtils { } // Performance optimization - ItemStackWrapper wrapper = new ItemStackWrapper(item); + if (!(item instanceof SlimefunItemStack)) { + item = new ItemStackWrapper(item); + } for (ItemStack stack : inventory.getStorageContents()) { if (stack == null || stack.getType() == Material.AIR) { continue; } - if (isItemSimilar(stack, wrapper, checkLore)) { + if (isItemSimilar(stack, item, checkLore, false)) { return true; } } @@ -241,7 +243,6 @@ public final class SlimefunUtils { return ((SlimefunItemStack) item).getItemId().equals(((SlimefunItemStack) sfitem).getItemId()); } - boolean sfItemHasMeta = sfitem.hasItemMeta(); if (item.hasItemMeta()) { ItemMeta itemMeta = item.getItemMeta(); @@ -255,13 +256,12 @@ public final class SlimefunUtils { ImmutableItemMeta meta = ((SlimefunItemStack) sfitem).getImmutableMeta(); return equalsItemMeta(itemMeta, meta, checkLore); } - - if (sfItemHasMeta) { + else if (sfitem.hasItemMeta()) { return equalsItemMeta(itemMeta, sfitem.getItemMeta(), checkLore); } } else { - return !sfItemHasMeta; + return !sfitem.hasItemMeta(); } return false; @@ -278,11 +278,17 @@ public final class SlimefunUtils { if (itemMeta.hasLore() && itemLore.isPresent()) { return equalsLore(itemMeta.getLore(), itemLore.get()); } - else return !itemMeta.hasLore() && !itemLore.isPresent(); + else { + return !itemMeta.hasLore() && !itemLore.isPresent(); + } + } + else { + return true; } - else return true; } - else return false; + else { + return false; + } } else if (!itemMeta.hasDisplayName() && !displayName.isPresent()) { Optional> itemLore = meta.getLore(); @@ -291,9 +297,13 @@ public final class SlimefunUtils { if (itemMeta.hasLore() && itemLore.isPresent()) { return equalsLore(itemMeta.getLore(), itemLore.get()); } - else return !itemMeta.hasLore() && !itemLore.isPresent(); + else { + return !itemMeta.hasLore() && !itemLore.isPresent(); + } + } + else { + return true; } - else return true; } else return false; } @@ -305,22 +315,34 @@ public final class SlimefunUtils { if (itemMeta.hasLore() && sfitemMeta.hasLore()) { return equalsLore(itemMeta.getLore(), sfitemMeta.getLore()); } - else return !itemMeta.hasLore() && !sfitemMeta.hasLore(); + else { + return !itemMeta.hasLore() && !sfitemMeta.hasLore(); + } + } + else { + return true; } - else return true; } - else return false; + else { + return false; + } } else if (!itemMeta.hasDisplayName() && !sfitemMeta.hasDisplayName()) { if (checkLore) { if (itemMeta.hasLore() && sfitemMeta.hasLore()) { return equalsLore(itemMeta.getLore(), sfitemMeta.getLore()); } - else return !itemMeta.hasLore() && !sfitemMeta.hasLore(); + else { + return !itemMeta.hasLore() && !sfitemMeta.hasLore(); + } + } + else { + return true; } - else return true; } - else return false; + else { + return false; + } } private static boolean equalsLore(List lore, List lore2) { From dcb00dff20965036a36e11dbe998e606d08e3ee1 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Jul 2020 01:08:23 +0200 Subject: [PATCH 20/26] [CI skip] Reduced technical debt --- .../implementation/SlimefunItems.java | 60 +++++++++---------- .../slimefun4/utils/LoreBuilder.java | 21 +++++++ .../Slimefun/api/SlimefunItemStack.java | 6 +- 3 files changed, 56 insertions(+), 31 deletions(-) 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 6c9b24e3c..fcf7b7034 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -144,11 +144,11 @@ public final class SlimefunItems { public static final SlimefunItemStack DIET_COOKIE = new SlimefunItemStack("DIET_COOKIE", Material.COOKIE, "&6Diet Cookie", "", "&aA very &olightweight &f&acookie."); public static final SlimefunItemStack MAGIC_SUGAR = new SlimefunItemStack("MAGIC_SUGAR", Material.SUGAR, "&6Magic Sugar", "", "&a&oFeel the Power of Hermes!"); public static final SlimefunItemStack MONSTER_JERKY = new SlimefunItemStack("MONSTER_JERKY", Material.ROTTEN_FLESH, "&6Monster Jerky", "", "&a&oNo longer hungry"); - public static final SlimefunItemStack APPLE_JUICE = new SlimefunItemStack("APPLE_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&cApple Juice", "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger"); - public static final SlimefunItemStack MELON_JUICE = new SlimefunItemStack("MELON_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&cMelon Juice", "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger"); - public static final SlimefunItemStack CARROT_JUICE = new SlimefunItemStack("CARROT_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&6Carrot Juice", "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger"); - public static final SlimefunItemStack PUMPKIN_JUICE = new SlimefunItemStack("PUMPKIN_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&6Pumpkin Juice", "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger"); - public static final SlimefunItemStack SWEET_BERRY_JUICE = new SlimefunItemStack("SWEET_BERRY_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&cSweet Berry Juice", "", "&7&oRestores &b&o" + "3.0" + " &7&oHunger"); + public static final SlimefunItemStack APPLE_JUICE = new SlimefunItemStack("APPLE_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&cApple Juice", "", LoreBuilder.hunger(3)); + public static final SlimefunItemStack MELON_JUICE = new SlimefunItemStack("MELON_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&cMelon Juice", "", LoreBuilder.hunger(3)); + public static final SlimefunItemStack CARROT_JUICE = new SlimefunItemStack("CARROT_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&6Carrot Juice", "", LoreBuilder.hunger(3)); + public static final SlimefunItemStack PUMPKIN_JUICE = new SlimefunItemStack("PUMPKIN_JUICE", Color.ORANGE, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&6Pumpkin Juice", "", LoreBuilder.hunger(3)); + public static final SlimefunItemStack SWEET_BERRY_JUICE = new SlimefunItemStack("SWEET_BERRY_JUICE", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 6, 0), "&cSweet Berry Juice", "", LoreBuilder.hunger(3)); public static final SlimefunItemStack GOLDEN_APPLE_JUICE = new SlimefunItemStack("GOLDEN_APPLE_JUICE", Color.YELLOW, new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 0), "&bGolden Apple Juice"); public static final SlimefunItemStack BEEF_JERKY = new SlimefunItemStack("BEEF_JERKY", Material.COOKED_BEEF, "&6Beef Jerky", "", "&fExtra saturating!"); @@ -161,14 +161,14 @@ public final class SlimefunItems { public static final SlimefunItemStack KELP_COOKIE = new SlimefunItemStack("KELP_COOKIE", Material.COOKIE, "&2Kelp Cookie"); /* Christmas */ - public static final SlimefunItemStack CHRISTMAS_MILK = new SlimefunItemStack("CHRISTMAS_MILK", Color.WHITE, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&6Glass of Milk", "", "&7&oRestores &b&o" + "2.5" + " &7&oHunger"); - public static final SlimefunItemStack CHRISTMAS_CHOCOLATE_MILK = new SlimefunItemStack("CHRISTMAS_CHOCOLATE_MILK", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 12, 0), "&6Chocolate Milk", "", "&7&oRestores &b&o" + "6.0" + " &7&oHunger"); - public static final SlimefunItemStack CHRISTMAS_EGG_NOG = new SlimefunItemStack("CHRISTMAS_EGG_NOG", Color.GRAY, new PotionEffect(PotionEffectType.SATURATION, 7, 0), "&aEgg Nog", "", "&7&oRestores &b&o" + "3.5" + " &7&oHunger"); - public static final SlimefunItemStack CHRISTMAS_APPLE_CIDER = new SlimefunItemStack("CHRISTMAS_APPLE_CIDER", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 14, 0), "&cApple Cider", "", "&7&oRestores &b&o" + "7.0" + " &7&oHunger"); + public static final SlimefunItemStack CHRISTMAS_MILK = new SlimefunItemStack("CHRISTMAS_MILK", Color.WHITE, new PotionEffect(PotionEffectType.SATURATION, 5, 0), "&6Glass of Milk", "", LoreBuilder.hunger(2.5)); + public static final SlimefunItemStack CHRISTMAS_CHOCOLATE_MILK = new SlimefunItemStack("CHRISTMAS_CHOCOLATE_MILK", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 12, 0), "&6Chocolate Milk", "", LoreBuilder.hunger(6)); + public static final SlimefunItemStack CHRISTMAS_EGG_NOG = new SlimefunItemStack("CHRISTMAS_EGG_NOG", Color.GRAY, new PotionEffect(PotionEffectType.SATURATION, 7, 0), "&aEgg Nog", "", LoreBuilder.hunger(3.5)); + public static final SlimefunItemStack CHRISTMAS_APPLE_CIDER = new SlimefunItemStack("CHRISTMAS_APPLE_CIDER", Color.RED, new PotionEffect(PotionEffectType.SATURATION, 14, 0), "&cApple Cider", "", LoreBuilder.hunger(7)); public static final SlimefunItemStack CHRISTMAS_COOKIE = new SlimefunItemStack("CHRISTMAS_COOKIE", Material.COOKIE, ChatUtils.christmas("Christmas Cookie")); public static final SlimefunItemStack CHRISTMAS_FRUIT_CAKE = new SlimefunItemStack("CHRISTMAS_FRUIT_CAKE", Material.PUMPKIN_PIE, ChatUtils.christmas("Fruit Cake")); public static final SlimefunItemStack CHRISTMAS_APPLE_PIE = new SlimefunItemStack("CHRISTMAS_APPLE_PIE", Material.PUMPKIN_PIE, "&fApple Pie"); - public static final SlimefunItemStack CHRISTMAS_HOT_CHOCOLATE = new SlimefunItemStack("CHRISTMAS_HOT_CHOCOLATE", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 14, 0), "&6Hot Chocolate", "", "&7&oRestores &b&o" + "7.0" + " &7&oHunger"); + public static final SlimefunItemStack CHRISTMAS_HOT_CHOCOLATE = new SlimefunItemStack("CHRISTMAS_HOT_CHOCOLATE", Color.MAROON, new PotionEffect(PotionEffectType.SATURATION, 14, 0), "&6Hot Chocolate", "", LoreBuilder.hunger(7)); public static final SlimefunItemStack CHRISTMAS_CAKE = new SlimefunItemStack("CHRISTMAS_CAKE", Material.PUMPKIN_PIE, ChatUtils.christmas("Christmas Cake")); public static final SlimefunItemStack CHRISTMAS_CARAMEL = new SlimefunItemStack("CHRISTMAS_CARAMEL", Material.BRICK, "&6Caramel"); public static final SlimefunItemStack CHRISTMAS_CARAMEL_APPLE = new SlimefunItemStack("CHRISTMAS_CARAMEL_APPLE", Material.APPLE, "&6Caramel Apple"); @@ -755,28 +755,28 @@ public final class SlimefunItems { public static final SlimefunItemStack AUTO_BREEDER = new SlimefunItemStack("AUTO_BREEDER", Material.HAY_BLOCK, "&eAuto-Breeder", "", "&fRuns on &aOrganic Food", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.powerBuffer(1024), "&8\u21E8 &e\u26A1 &760 J/Animal"); public static final SlimefunItemStack ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9???"); - public static final SlimefunItemStack WHEAT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_WHEAT", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Wheat"); - public static final SlimefunItemStack CARROT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_CARROT", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Carrots"); - public static final SlimefunItemStack POTATO_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_POTATO", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Potatoes"); - public static final SlimefunItemStack SEEDS_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SEEDS", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Seeds"); - public static final SlimefunItemStack BEETROOT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_BEETROOT", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Beetroot"); - public static final SlimefunItemStack MELON_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_MELON", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Melon"); - public static final SlimefunItemStack APPLE_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_APPLE", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Apple"); - public static final SlimefunItemStack SWEET_BERRIES_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SWEET_BERRIES", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Sweet Berries"); - public static final SlimefunItemStack KELP_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_KELP", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Dried Kelp"); - public static final SlimefunItemStack COCOA_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_COCOA", HeadTexture.FILLED_CAN, "&aOrganic Food", "&7Content: &9Cocoa Beans"); + public static final SlimefunItemStack WHEAT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_WHEAT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Wheat"); + public static final SlimefunItemStack CARROT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_CARROT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Carrots"); + public static final SlimefunItemStack POTATO_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_POTATO", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Potatoes"); + public static final SlimefunItemStack SEEDS_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SEEDS", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Seeds"); + public static final SlimefunItemStack BEETROOT_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_BEETROOT", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Beetroot"); + public static final SlimefunItemStack MELON_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_MELON", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Melon"); + public static final SlimefunItemStack APPLE_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_APPLE", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Apple"); + public static final SlimefunItemStack SWEET_BERRIES_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_SWEET_BERRIES", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Sweet Berries"); + public static final SlimefunItemStack KELP_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_KELP", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Dried Kelp"); + public static final SlimefunItemStack COCOA_ORGANIC_FOOD = new SlimefunItemStack("ORGANIC_FOOD_COCOA", HeadTexture.FILLED_CAN, ORGANIC_FOOD.getDisplayName(), "&7Content: &9Cocoa Beans"); public static final SlimefunItemStack FERTILIZER = new SlimefunItemStack("FERTILIZER", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9???"); - public static final SlimefunItemStack WHEAT_FERTILIZER = new SlimefunItemStack("FERTILIZER_WHEAT", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Wheat"); - public static final SlimefunItemStack CARROT_FERTILIZER = new SlimefunItemStack("FERTILIZER_CARROT", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Carrots"); - public static final SlimefunItemStack POTATO_FERTILIZER = new SlimefunItemStack("FERTILIZER_POTATO", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Potatoes"); - public static final SlimefunItemStack SEEDS_FERTILIZER = new SlimefunItemStack("FERTILIZER_SEEDS", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Seeds"); - public static final SlimefunItemStack BEETROOT_FERTILIZER = new SlimefunItemStack("FERTILIZER_BEETROOT", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Beetroot"); - public static final SlimefunItemStack MELON_FERTILIZER = new SlimefunItemStack("FERTILIZER_MELON", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Melon"); - public static final SlimefunItemStack APPLE_FERTILIZER = new SlimefunItemStack("FERTILIZER_APPLE", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Apple"); - public static final SlimefunItemStack SWEET_BERRIES_FERTILIZER = new SlimefunItemStack("FERTILIZER_SWEET_BERRIES", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Sweet Berries"); - public static final SlimefunItemStack KELP_FERTILIZER = new SlimefunItemStack("FERTILIZER_KELP", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Dried Kelp"); - public static final SlimefunItemStack COCOA_FERTILIZER = new SlimefunItemStack("FERTILIZER_COCOA", HeadTexture.FILLED_CAN, "&aOrganic Fertilizer", "&7Content: &9Cocoa beans"); + public static final SlimefunItemStack WHEAT_FERTILIZER = new SlimefunItemStack("FERTILIZER_WHEAT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Wheat"); + public static final SlimefunItemStack CARROT_FERTILIZER = new SlimefunItemStack("FERTILIZER_CARROT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Carrots"); + public static final SlimefunItemStack POTATO_FERTILIZER = new SlimefunItemStack("FERTILIZER_POTATO", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Potatoes"); + public static final SlimefunItemStack SEEDS_FERTILIZER = new SlimefunItemStack("FERTILIZER_SEEDS", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Seeds"); + public static final SlimefunItemStack BEETROOT_FERTILIZER = new SlimefunItemStack("FERTILIZER_BEETROOT", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Beetroot"); + public static final SlimefunItemStack MELON_FERTILIZER = new SlimefunItemStack("FERTILIZER_MELON", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Melon"); + public static final SlimefunItemStack APPLE_FERTILIZER = new SlimefunItemStack("FERTILIZER_APPLE", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Apple"); + public static final SlimefunItemStack SWEET_BERRIES_FERTILIZER = new SlimefunItemStack("FERTILIZER_SWEET_BERRIES", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Sweet Berries"); + public static final SlimefunItemStack KELP_FERTILIZER = new SlimefunItemStack("FERTILIZER_KELP", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Dried Kelp"); + public static final SlimefunItemStack COCOA_FERTILIZER = new SlimefunItemStack("FERTILIZER_COCOA", HeadTexture.FILLED_CAN, FERTILIZER.getDisplayName(), "&7Content: &9Cocoa beans"); public static final SlimefunItemStack ANIMAL_GROWTH_ACCELERATOR = new SlimefunItemStack("ANIMAL_GROWTH_ACCELERATOR", Material.HAY_BLOCK, "&bAnimal Growth Accelerator", "", "&fRuns on &aOrganic Food", "", 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, "&aCrop Growth Accelerator", "", "&fRuns on &aOrganic Fertilizer", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Radius: 7x7", "&8\u21E8 &7Speed: &a3/time", LoreBuilder.powerBuffer(1024), LoreBuilder.powerPerSecond(50)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java index 49d3ff06d..5ee60be57 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/LoreBuilder.java @@ -1,9 +1,24 @@ package io.github.thebusybiscuit.slimefun4.utils; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.util.Locale; + import io.github.thebusybiscuit.slimefun4.core.attributes.MachineTier; import io.github.thebusybiscuit.slimefun4.core.attributes.MachineType; import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; +import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; +/** + * This utility class provides a few handy methods and constants to build the lore of any + * {@link SlimefunItemStack}. It is mostly used directly inside the class {@link SlimefunItems}. + * + * @author TheBusyBiscuit + * + * @see SlimefunItems + * + */ public final class LoreBuilder { public static final String HAZMAT_SUIT_REQUIRED = "&8\u21E8 &4Hazmat Suit required!"; @@ -12,6 +27,8 @@ public final class LoreBuilder { public static final String RIGHT_CLICK_TO_OPEN = "&eRight Click&7 to open"; public static final String CROUCH_TO_USE = "&eCrouch&7 to use"; + private static final DecimalFormat hungerFormat = new DecimalFormat("#.0", DecimalFormatSymbols.getInstance(Locale.ROOT)); + private LoreBuilder() {} public static String radioactive(Radioactivity radioactivity) { @@ -46,4 +63,8 @@ public final class LoreBuilder { return "&8\u21E8 &7Material: &b" + material; } + public static String hunger(double value) { + return "&7&oRestores &b&o" + hungerFormat.format(value) + " &7&oHunger"; + } + } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index 22c1ebd9a..fb72f1f37 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -231,7 +231,7 @@ public class SlimefunItemStack extends CustomItem { throw new WrongItemStackException(id + " is not mutable."); } } - + public void lock() { locked = true; } @@ -250,6 +250,10 @@ public class SlimefunItemStack extends CustomItem { return Optional.ofNullable(texture); } + public String getDisplayName() { + return immutableMeta.getDisplayName().orElse(null); + } + private static ItemStack getSkull(String id, String texture) { if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) { return new ItemStack(Material.PLAYER_HEAD); From 90685edae6980934dd82494d34eb9e98af64bce3 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Jul 2020 01:32:43 +0200 Subject: [PATCH 21/26] Added a permission node for the debug fish --- CHANGELOG.md | 1 + .../slimefun4/core/commands/SubCommand.java | 28 +++++++++++++-- .../commands/subcommands/BackpackCommand.java | 12 +------ .../commands/subcommands/CheatCommand.java | 12 +------ .../subcommands/DebugFishCommand.java | 16 ++------- .../commands/subcommands/GiveCommand.java | 12 +------ .../commands/subcommands/GuideCommand.java | 12 +------ .../commands/subcommands/HelpCommand.java | 12 +------ .../subcommands/OpenGuideCommand.java | 12 +------ .../commands/subcommands/ResearchCommand.java | 12 +------ .../commands/subcommands/SearchCommand.java | 12 +------ .../commands/subcommands/StatsCommand.java | 12 +------ .../subcommands/TeleporterCommand.java | 12 +------ .../commands/subcommands/TimingsCommand.java | 12 +------ .../commands/subcommands/VersionsCommand.java | 35 ++++++++----------- src/main/resources/plugin.yml | 3 ++ 16 files changed, 57 insertions(+), 158 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 27a1e0044..d09af459c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ * Added Bee protection to Hazmat Suit * Added Enchantment Rune * Added Tape Measure +* Added a permission node for /sf debug_fish #### Changes * Refactored and reworked the Generator API 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 ede461878..4edbd09c4 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 @@ -4,6 +4,7 @@ import java.util.Map; 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; @@ -23,14 +24,35 @@ public abstract class SubCommand { protected final SlimefunPlugin plugin; protected final SlimefunCommand cmd; - protected SubCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { + private final String name; + private final boolean hidden; + + protected SubCommand(SlimefunPlugin plugin, SlimefunCommand cmd, String name, boolean hidden) { this.plugin = plugin; this.cmd = cmd; + + this.name = name; + this.hidden = hidden; } - public abstract String getName(); + /** + * 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} + */ + public final String getName() { + return name; + } - public abstract boolean isHidden(); + /** + * This method returns whether this {@link SubCommand} is hidden from the {@link HelpCommand}. + * + * @return Whether to hide this {@link SubCommand} + */ + public final boolean isHidden() { + return hidden; + } protected void recordUsage(Map commandUsage) { commandUsage.merge(this, 1, Integer::sum); 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 f607010c3..1b1478e30 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 @@ -17,12 +17,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun; class BackpackCommand extends SubCommand { BackpackCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "backpack"; + super(plugin, cmd, "backpack", false); } @Override @@ -30,11 +25,6 @@ class BackpackCommand extends SubCommand { return "commands.backpack.description"; } - @Override - public boolean isHidden() { - return false; - } - @Override public void onExecute(CommandSender sender, String[] args) { if (!(sender instanceof Player) || !sender.hasPermission("slimefun.command.backpack")) { 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 faa553341..450abd94d 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 @@ -11,17 +11,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class CheatCommand extends SubCommand { CheatCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "cheat"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "cheat", false); } @Override 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 dcc63f273..f1e8656fc 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 @@ -11,23 +11,13 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class DebugFishCommand extends SubCommand { DebugFishCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "debug_fish"; - } - - @Override - public boolean isHidden() { - return true; + super(plugin, cmd, "debug_fish", true); } @Override public void onExecute(CommandSender sender, String[] args) { - if (sender instanceof Player && sender.isOp()) { - ((Player) sender).getInventory().addItem(SlimefunItems.DEBUG_FISH); + if (sender instanceof Player && sender.hasPermission("slimefun.debugging")) { + ((Player) sender).getInventory().addItem(SlimefunItems.DEBUG_FISH.clone()); } else { SlimefunPlugin.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 8c9457845..eb9c8d131 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 @@ -22,17 +22,7 @@ class GiveCommand extends SubCommand { private static final String PLACEHOLDER_AMOUNT = "%amount%"; GiveCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "give"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "give", false); } @Override 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 a233cc3f5..457151115 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 @@ -12,17 +12,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class GuideCommand extends SubCommand { GuideCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "guide"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "guide", false); } @Override 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 1c241462d..43e43feb3 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 @@ -9,17 +9,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class HelpCommand extends SubCommand { HelpCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "help"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "help", false); } @Override 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 a286db515..ab6e087b2 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 @@ -12,17 +12,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class OpenGuideCommand extends SubCommand { OpenGuideCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "open_guide"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "open_guide", false); } @Override 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 1ea35f95b..bb230acda 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 @@ -19,17 +19,7 @@ class ResearchCommand extends SubCommand { private static final String PLACEHOLDER_RESEARCH = "%research%"; ResearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "research"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "research", false); } @Override 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 60186e0c4..22169a7ae 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 @@ -14,17 +14,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class SearchCommand extends SubCommand { SearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "search"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "search", false); } @Override 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 29e3b861a..a2e9628b3 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 @@ -15,17 +15,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class StatsCommand extends SubCommand { StatsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "stats"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "stats", false); } @Override 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 75437e35e..8031116ca 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 @@ -13,17 +13,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class TeleporterCommand extends SubCommand { TeleporterCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "teleporter"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "teleporter", false); } @Override 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 2b85e48aa..7b5e4b7e9 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 @@ -10,17 +10,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; class TimingsCommand extends SubCommand { TimingsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "timings"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "timings", false); } @Override 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 9be653ac9..505f29c62 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 @@ -2,32 +2,23 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands; import java.util.Collection; +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.command.ConsoleCommandSender; +import org.bukkit.plugin.Plugin; + import io.github.thebusybiscuit.cscorelib2.chat.ChatColors; import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils; import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand; import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; -import org.bukkit.command.ConsoleCommandSender; -import org.bukkit.plugin.Plugin; import io.papermc.lib.PaperLib; class VersionsCommand extends SubCommand { VersionsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) { - super(plugin, cmd); - } - - @Override - public String getName() { - return "versions"; - } - - @Override - public boolean isHidden() { - return false; + super(plugin, cmd, "versions", false); } @Override @@ -37,8 +28,8 @@ class VersionsCommand extends SubCommand { // so we will just fix this inconsistency for them :) String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName(); + sender.sendMessage(ChatColor.GRAY + "This Server uses the following setup of Slimefun:"); sender.sendMessage(ChatColors.color("&a" + serverSoftware + " &2" + ReflectionUtils.getVersion())); - sender.sendMessage(""); sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion())); sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion())); @@ -47,20 +38,22 @@ class VersionsCommand extends SubCommand { } if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) { - sender.sendMessage(ChatColor.YELLOW + "Backwards compatibility enabled!"); + sender.sendMessage(ChatColor.RED + "Backwards compatibility enabled!"); } sender.sendMessage(""); Collection addons = SlimefunPlugin.getInstalledAddons(); - sender.sendMessage(ChatColors.color("&7Installed Addons &8(" + addons.size() + ")")); + sender.sendMessage(ChatColors.color("&7Installed Addons: &8(" + addons.size() + ")")); for (Plugin plugin : addons) { + String version = plugin.getDescription().getVersion(); + if (Bukkit.getPluginManager().isPluginEnabled(plugin)) { - sender.sendMessage(ChatColors.color(" &a" + plugin.getName() + " &2v" + plugin.getDescription().getVersion())); + sender.sendMessage(ChatColor.GREEN + " " + plugin.getName() + ChatColor.DARK_GREEN + " v" + version); } else { - sender.sendMessage(ChatColors.color(" &c" + plugin.getName() + " &4v" + plugin.getDescription().getVersion())); + sender.sendMessage(ChatColor.RED + " " + plugin.getName() + ChatColor.DARK_RED + " v" + version); } } } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b991fb322..1841a7839 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -58,3 +58,6 @@ permissions: slimefun.inventory.bypass: description: Allows you to open all Slimefun Machines default: op + slimefun.debugging: + description: Allows you to use the debugging tool from Slimefun + default: op From df4f31667587330c49ba47668bffa73975c82896 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Jul 2020 01:39:10 +0200 Subject: [PATCH 22/26] Minor change --- .../me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index fb72f1f37..96df69a95 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -251,6 +251,11 @@ public class SlimefunItemStack extends CustomItem { } public String getDisplayName() { + if (immutableMeta == null) { + // Just to be extra safe + return null; + } + return immutableMeta.getDisplayName().orElse(null); } From 5d22bfb109981bbf1f15515c0ffe77f0dc7be806 Mon Sep 17 00:00:00 2001 From: Scott Gomez Andoy Date: Thu, 30 Jul 2020 23:59:34 +0000 Subject: [PATCH 23/26] Translate recipes_tl.yml via GitLocalize --- src/main/resources/languages/recipes_tl.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/languages/recipes_tl.yml b/src/main/resources/languages/recipes_tl.yml index 4ca058aef..e5b7025b9 100644 --- a/src/main/resources/languages/recipes_tl.yml +++ b/src/main/resources/languages/recipes_tl.yml @@ -71,7 +71,7 @@ slimefun: lore: - I-craft ang item na ito tulad ng ipinakita - gamit ang Ancient Altar. - - Hanapin ang Ancient Altar para sa karagdagang Impormasyon. + - Hanapin ang Ancient Altar para sa mga karagdagang Impormasyon. heated_pressure_chamber: name: Heated Pressure Chamber lore: From 446191d4bfaabadafc56a9f2a63740d5725fe831 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Jul 2020 20:14:48 +0200 Subject: [PATCH 24/26] Fixes #2156 --- CHANGELOG.md | 1 + .../services/localization/Translators.java | 1 + .../listeners/DebugFishListener.java | 54 +++++++++++++------ 3 files changed, 39 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d09af459c..2da796bc2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,7 @@ * Fixed Talismans sometimes not getting consumed properly * Fixed old Infused Magnets not working * Fixed old GPS Emergency Transmitters not working +* Fixed #2156 ## Release Candidate 14 (12 Jul 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java index 088856ec1..f44127127 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Translators.java @@ -38,6 +38,7 @@ public class Translators { addTranslator("ThatsCube", SupportedLanguage.ITALIAN, true); addTranslator("alessandrobasi", SupportedLanguage.ITALIAN, true); addTranslator("dracrus", SupportedLanguage.ITALIAN, true); + addTranslator("prolletto64", SupportedLanguage.ITALIAN, true); // Translators - Latvian addTranslator("AgnisT", "NIKNAIZ", SupportedLanguage.LATVIAN, true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java index a463f2324..ad9edce67 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; +import java.util.logging.Level; + import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.Skull; @@ -23,8 +25,16 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture; import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; import me.mrCookieSlime.Slimefun.api.BlockStorage; +import me.mrCookieSlime.Slimefun.api.Slimefun; import me.mrCookieSlime.Slimefun.api.energy.ChargableBlock; +/** + * This {@link Listener} is responsible for handling our debugging tool, the debug fish. + * This is where the functionality of this item is implemented. + * + * @author TheBusyBiscuit + * + */ public class DebugFishListener implements Listener { private final String greenCheckmark; @@ -45,28 +55,38 @@ public class DebugFishListener implements Listener { Player p = e.getPlayer(); - if (p.isOp() && SlimefunUtils.isItemSimilar(e.getItem(), SlimefunItems.DEBUG_FISH, true)) { + if (SlimefunUtils.isItemSimilar(e.getItem(), SlimefunItems.DEBUG_FISH, true, false)) { e.setCancelled(true); - if (e.getAction() == Action.LEFT_CLICK_BLOCK) { - if (p.isSneaking()) { - if (BlockStorage.hasBlockInfo(e.getClickedBlock())) { - BlockStorage.clearBlockInfo(e.getClickedBlock()); + if (p.hasPermission("slimefun.debugging")) { + if (e.getAction() == Action.LEFT_CLICK_BLOCK) { + if (p.isSneaking()) { + if (BlockStorage.hasBlockInfo(e.getClickedBlock())) { + BlockStorage.clearBlockInfo(e.getClickedBlock()); + } + } + else { + e.setCancelled(false); } } - else { - e.setCancelled(false); + else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { + if (p.isSneaking()) { + Block b = e.getClickedBlock().getRelative(e.getBlockFace()); + b.setType(Material.PLAYER_HEAD); + SkullBlock.setFromHash(b, HeadTexture.MISSING_TEXTURE.getTexture()); + } + else if (BlockStorage.hasBlockInfo(e.getClickedBlock())) { + try { + sendInfo(p, e.getClickedBlock()); + } + catch (Exception x) { + Slimefun.getLogger().log(Level.SEVERE, "An Exception occured while using a Debug-Fish", x); + } + } } } - else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { - if (p.isSneaking()) { - Block b = e.getClickedBlock().getRelative(e.getBlockFace()); - b.setType(Material.PLAYER_HEAD); - SkullBlock.setFromHash(b, HeadTexture.MISSING_TEXTURE.getTexture()); - } - else if (BlockStorage.hasBlockInfo(e.getClickedBlock())) { - sendInfo(p, e.getClickedBlock()); - } + else { + SlimefunPlugin.getLocalization().sendMessage(p, "messages.no-permission", true); } } } @@ -108,7 +128,7 @@ public class DebugFishListener implements Listener { else { p.sendMessage(ChatColors.color("&dTicking: " + redCross)); } - + if (SlimefunPlugin.getProfiler().hasTimings(b)) { p.sendMessage(ChatColors.color(" &dTimings: &e" + SlimefunPlugin.getProfiler().getTime(b))); p.sendMessage(ChatColors.color(" &dTotal Timings: &e" + SlimefunPlugin.getProfiler().getTime(item))); From e380f8b9727774b216cd1265d01526ba5dfcde20 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Jul 2020 20:18:51 +0200 Subject: [PATCH 25/26] Fixes #2165 --- CHANGELOG.md | 1 + .../implementation/items/RadioactiveItem.java | 23 +++++++++++++++++-- .../setup/SlimefunItemSetup.java | 8 +++---- 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da796bc2..5811da295 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -67,6 +67,7 @@ * Fixed old Infused Magnets not working * Fixed old GPS Emergency Transmitters not working * Fixed #2156 +* Fixed #2165 ## Release Candidate 14 (12 Jul 2020) 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 3135ee83c..e3966b274 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 @@ -43,10 +43,29 @@ public class RadioactiveItem extends SlimefunItem implements Radioactive, NotPla * The recipe of how to craft this {@link SlimefunItem} */ public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { - super(category, item, recipeType, recipe); + this(category, radioactivity, item, recipeType, recipe, null); + } + + /** + * This will create a new {@link RadioactiveItem} with the given level of {@link Radioactivity} + * + * @param category + * The {@link Category} of this {@link SlimefunItem} + * @param radioactivity + * the level of {@link Radioactivity} + * @param item + * the {@link SlimefunItemStack} this {@link SlimefunItem} represents + * @param recipeType + * The {@link RecipeType} for this item + * @param recipe + * The recipe of how to craft this {@link SlimefunItem} + * @param recipeOutput + * The recipe output + */ + public RadioactiveItem(Category category, Radioactivity radioactivity, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) { + super(category, item, recipeType, recipe, recipeOutput); this.radioactivity = radioactivity; - addItemHandler(onRightClick()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 6a0ddd8f3..05c37852d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -2781,12 +2781,12 @@ public final class SlimefunItemSetup { .register(plugin); new RadioactiveItem(categories.resources, Radioactivity.VERY_HIGH, SlimefunItems.ENRICHED_NETHER_ICE, RecipeType.HEATED_PRESSURE_CHAMBER, - new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM, null, null, null, null, null, null, null}) - .register(plugin); + new ItemStack[] {SlimefunItems.NETHER_ICE, SlimefunItems.PLUTONIUM, null, null, null, null, null, null, null}, + new SlimefunItemStack(SlimefunItems.ENRICHED_NETHER_ICE, 4)).register(plugin); new ElevatorPlate(categories.gps, SlimefunItems.ELEVATOR_PLATE, RecipeType.ENHANCED_CRAFTING_TABLE, new ItemStack[] {null, new ItemStack(Material.STONE_PRESSURE_PLATE), null, new ItemStack(Material.PISTON), SlimefunItems.ELECTRIC_MOTOR, new ItemStack(Material.PISTON), SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ALUMINUM_BRONZE_INGOT}, - new CustomItem(SlimefunItems.ELEVATOR_PLATE, 2)) + new SlimefunItemStack(SlimefunItems.ELEVATOR_PLATE, 2)) .register(plugin); new FoodFabricator(categories.electricity, SlimefunItems.FOOD_FABRICATOR, RecipeType.ENHANCED_CRAFTING_TABLE, @@ -3023,7 +3023,7 @@ public final class SlimefunItemSetup { new CoolantCell(categories.technicalComponents, SlimefunItems.NETHER_ICE_COOLANT_CELL, RecipeType.HEATED_PRESSURE_CHAMBER, new ItemStack[] {SlimefunItems.ENRICHED_NETHER_ICE, null, null, null, null, null, null, null, null}, - new SlimefunItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL, 4)) + new SlimefunItemStack(SlimefunItems.NETHER_ICE_COOLANT_CELL, 8)) .register(plugin); new RadioactiveItem(categories.resources, Radioactivity.HIGH, SlimefunItems.NEPTUNIUM, RecipeType.NUCLEAR_REACTOR, From 2fc18aed0a7df1cfdc9e39c986d138dca10faf91 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Fri, 31 Jul 2020 20:24:58 +0200 Subject: [PATCH 26/26] Fixes #2162 --- CHANGELOG.md | 3 +++ .../listeners/AncientAltarListener.java | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5811da295..dbf73e1ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,8 @@ * General performance improvements for Talismans * General performance improvements for GPS Emergency Transmitters * General performance improvements for Infused Magnets +* Ancient Altars now support for protection plugins +* Ancient Pedestals now support for protection plugins #### Fixes * Fixed Slimefun Armor sometimes not applying its effects @@ -68,6 +70,7 @@ * Fixed old GPS Emergency Transmitters not working * Fixed #2156 * Fixed #2165 +* Fixed #2162 ## Release Candidate 14 (12 Jul 2020) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 825859459..518ae597d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -29,6 +29,7 @@ import org.bukkit.util.Vector; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.item.CustomItem; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; @@ -128,6 +129,11 @@ public class AncientAltarListener implements Listener { return; } + if (!SlimefunPlugin.getProtectionManager().hasPermission(p, pedestal, ProtectableAction.ACCESS_INVENTORIES)) { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + return; + } + // getting the currently placed item Item stack = findItem(pedestal); @@ -157,6 +163,11 @@ public class AncientAltarListener implements Listener { } private void useAltar(Block altar, Player p) { + if (!SlimefunPlugin.getProtectionManager().hasPermission(p, altar, ProtectableAction.ACCESS_INVENTORIES)) { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + return; + } + ItemStack catalyst = new CustomItem(p.getInventory().getItemInMainHand(), 1); List pedestals = getPedestals(altar);