mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Merge branch 'master' of https://github.com/Slimefun/Slimefun4.git into
chore/has-unlocked Conflicts: src/main/java/io/github/thebusybiscuit/slimefun4/core/categories/LockedCategory.java src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java
This commit is contained in:
commit
5d4e22c4b5
6
.github/CODEOWNERS
vendored
6
.github/CODEOWNERS
vendored
@ -5,3 +5,9 @@
|
|||||||
/.github/ @Slimefun/slimefun4-maintainers
|
/.github/ @Slimefun/slimefun4-maintainers
|
||||||
pom.xml @Slimefun/slimefun4-maintainers
|
pom.xml @Slimefun/slimefun4-maintainers
|
||||||
CONTRIBUTING.md @Slimefun/slimefun4-maintainers
|
CONTRIBUTING.md @Slimefun/slimefun4-maintainers
|
||||||
|
|
||||||
|
# Changes to the Issue templates need to be checked by the triage team
|
||||||
|
/.github/ISSUE_TEMPLATE/ @Slimefun/bug-testers
|
||||||
|
|
||||||
|
# This file is handled by TheBusyBiscuit (admins have overwrite access anyway)
|
||||||
|
/.github/CODEOWNERS @TheBusyBiscuit
|
||||||
|
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
2
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@ -2,7 +2,7 @@
|
|||||||
name: Bug Report
|
name: Bug Report
|
||||||
about: Report a Bug or an Issue with Slimefun 4.
|
about: Report a Bug or an Issue with Slimefun 4.
|
||||||
title: ''
|
title: ''
|
||||||
labels: '🐞 Bug Report'
|
labels: "\U0001F3AF Needs testing, \U0001F41E Bug Report"
|
||||||
assignees: ''
|
assignees: ''
|
||||||
|
|
||||||
---
|
---
|
||||||
|
3
.github/TRIAGE_WORKFLOW.svg
vendored
Normal file
3
.github/TRIAGE_WORKFLOW.svg
vendored
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 41 KiB |
2
.github/workflows/closed-issues-reason.yml
vendored
2
.github/workflows/closed-issues-reason.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
token: ${{ secrets.ACCESS_TOKEN }}
|
token: ${{ secrets.ACCESS_TOKEN }}
|
||||||
issue_number: ${{ github.event.issue.number }}
|
issue_number: ${{ github.event.issue.number }}
|
||||||
labels: 'Resolved'
|
labels: '✔ Resolved'
|
||||||
- uses: maxkomarychev/octions/octions/issues/create-comment@master
|
- uses: maxkomarychev/octions/octions/issues/create-comment@master
|
||||||
id: comment
|
id: comment
|
||||||
if: contains(steps.resolved.outputs.issues, github.event.issue.number) == false
|
if: contains(steps.resolved.outputs.issues, github.event.issue.number) == false
|
||||||
|
2
.github/workflows/discord-webhook.yml
vendored
2
.github/workflows/discord-webhook.yml
vendored
@ -6,6 +6,8 @@ on:
|
|||||||
- 'src/**'
|
- 'src/**'
|
||||||
- '!src/main/resources/languages/**'
|
- '!src/main/resources/languages/**'
|
||||||
- 'pom.xml'
|
- 'pom.xml'
|
||||||
|
tags-ignore:
|
||||||
|
- 'RC.*'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
report:
|
report:
|
||||||
|
23
.github/workflows/url-checker.yml
vendored
23
.github/workflows/url-checker.yml
vendored
@ -1,23 +0,0 @@
|
|||||||
name: URL Validator
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check:
|
|
||||||
|
|
||||||
name: URL Checker
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: URL-checker
|
|
||||||
uses: SuperKogito/URLs-checker@0.2.1
|
|
||||||
with:
|
|
||||||
git_path: https://github.com/Slimefun/Slimefun4
|
|
||||||
file_types: .md,.java,.yml
|
|
||||||
print_all: false
|
|
||||||
retry_count: 2
|
|
||||||
## These URLs will always be correct, even if their services may be offline right now
|
|
||||||
white_listed_patterns: http://textures.minecraft.net/texture/,https://pastebin.com/,https://www.spigotmc.org/threads/spigot-bungeecord-1-16-1.447405/#post-3852349,https://gitlocalize.com/repo/3841
|
|
26
CHANGELOG.md
26
CHANGELOG.md
@ -2,7 +2,7 @@
|
|||||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||||
**Table of contents**
|
**Table of contents**
|
||||||
|
|
||||||
- [Release Candidate 19 (TBD)](#release-candidate-19-tbd)
|
- [Release Candidate 19 (11 Jan 2021)](#release-candidate-19-11-jan-2021)
|
||||||
- [Release Candidate 18 (03 Dec 2020)](#release-candidate-18-03-dec-2020)
|
- [Release Candidate 18 (03 Dec 2020)](#release-candidate-18-03-dec-2020)
|
||||||
- [Release Candidate 17 (17 Oct 2020)](#release-candidate-17-17-oct-2020)
|
- [Release Candidate 17 (17 Oct 2020)](#release-candidate-17-17-oct-2020)
|
||||||
- [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020)
|
- [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020)
|
||||||
@ -24,14 +24,32 @@
|
|||||||
|
|
||||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||||
|
|
||||||
## Release Candidate 19 (TBD)
|
## Release Candidate 20 (TBD)
|
||||||
|
|
||||||
|
#### Additions
|
||||||
|
|
||||||
|
#### Changes
|
||||||
|
|
||||||
|
#### Fixes
|
||||||
|
* Fixed elevator floor order
|
||||||
|
* Fixed #2449
|
||||||
|
* Fixed #2511
|
||||||
|
* Fixed #2636
|
||||||
|
* Fixed a threading issue related to BlockStates and persistent data
|
||||||
|
|
||||||
|
## Release Candidate 19 (11 Jan 2021)
|
||||||
|
|
||||||
#### Additions
|
#### Additions
|
||||||
* Added Bee Armor (1.15+ only)
|
* Added Bee Armor (1.15+ only)
|
||||||
|
* (API) Added AndroidFarmEvent
|
||||||
|
|
||||||
#### Changes
|
#### Changes
|
||||||
* Performance optimizations for Cargo networks
|
* Performance optimizations for Cargo networks
|
||||||
* Removed an old version of bStats
|
* Removed an old version of bStats
|
||||||
|
* CraftBukkit is officially no longer supported, Slimefun will now be disabled on old builds of CraftBukkit
|
||||||
|
* Removed the deprecated ItemManipulationAPI for BlockMenus
|
||||||
|
* Removed the "Written Book" variant of the Slimefun Guide
|
||||||
|
* The Elevator has an Inventory menu now
|
||||||
|
|
||||||
#### Fixes
|
#### Fixes
|
||||||
* Fixed a couple of compatibility issues with ItemsAdder
|
* Fixed a couple of compatibility issues with ItemsAdder
|
||||||
@ -40,6 +58,10 @@
|
|||||||
* Fixed #2636
|
* Fixed #2636
|
||||||
* Fixed some backpack opening issues
|
* Fixed some backpack opening issues
|
||||||
* Fixed #2647
|
* Fixed #2647
|
||||||
|
* Fixed #2664
|
||||||
|
* Fixed #2655
|
||||||
|
* Fixed /sf timings --verbose not working correctly
|
||||||
|
* Fixed #2675
|
||||||
|
|
||||||
## Release Candidate 18 (03 Dec 2020)
|
## Release Candidate 18 (03 Dec 2020)
|
||||||
|
|
||||||
|
40
pom.xml
40
pom.xml
@ -9,10 +9,11 @@
|
|||||||
|
|
||||||
<!-- Our default version will be UNOFFICIAL, this will prevent auto updates -->
|
<!-- Our default version will be UNOFFICIAL, this will prevent auto updates -->
|
||||||
<!-- from overriding our local test file -->
|
<!-- from overriding our local test file -->
|
||||||
<version>4.8-UNOFFICIAL</version>
|
<version>4.9-UNOFFICIAL</version>
|
||||||
<inceptionYear>2013</inceptionYear>
|
<inceptionYear>2013</inceptionYear>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<!-- Project Info -->
|
||||||
<description>Slimefun is a Spigot/Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server.</description>
|
<description>Slimefun is a Spigot/Paper plugin that simulates a modpack-like atmosphere by adding over 500 new items and recipes to your Minecraft Server.</description>
|
||||||
<url>https://github.com/Slimefun/Slimefun4</url>
|
<url>https://github.com/Slimefun/Slimefun4</url>
|
||||||
|
|
||||||
@ -33,11 +34,13 @@
|
|||||||
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
|
<sonar.coverage.jacoco.xmlReportPaths>target/site/jacoco/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
<!-- Bug Tracker -->
|
||||||
<issueManagement>
|
<issueManagement>
|
||||||
<system>GitHub Issues</system>
|
<system>GitHub Issues</system>
|
||||||
<url>https://github.com/Slimefun/Slimefun4/issues</url>
|
<url>https://github.com/Slimefun/Slimefun4/issues</url>
|
||||||
</issueManagement>
|
</issueManagement>
|
||||||
|
|
||||||
|
<!-- License -->
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
<name>GNU General Public License v3.0</name>
|
<name>GNU General Public License v3.0</name>
|
||||||
@ -46,6 +49,7 @@
|
|||||||
</license>
|
</license>
|
||||||
</licenses>
|
</licenses>
|
||||||
|
|
||||||
|
<!-- The repositories which host our dependencies -->
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
@ -77,11 +81,13 @@
|
|||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
|
<!-- Build settings -->
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
<sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
|
||||||
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
<testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
|
||||||
<defaultGoal>clean package</defaultGoal>
|
<defaultGoal>clean package</defaultGoal>
|
||||||
|
|
||||||
|
<!-- The name of the final jar -->
|
||||||
<finalName>${project.name} v${project.version}</finalName>
|
<finalName>${project.name} v${project.version}</finalName>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -104,6 +110,7 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-source-plugin</artifactId>
|
<artifactId>maven-source-plugin</artifactId>
|
||||||
<version>3.2.1</version>
|
<version>3.2.1</version>
|
||||||
|
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>attach-sources</id>
|
<id>attach-sources</id>
|
||||||
@ -119,6 +126,11 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>3.0.0-M5</version>
|
<version>3.0.0-M5</version>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<junitArtifactName>org.junit.jupiter:junit-jupiter</junitArtifactName>
|
||||||
|
<trimStackTrace>false</trimStackTrace>
|
||||||
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Sonarcloud Scanner -->
|
<!-- Sonarcloud Scanner -->
|
||||||
@ -137,6 +149,7 @@
|
|||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>prepare</id>
|
<id>prepare</id>
|
||||||
|
|
||||||
<goals>
|
<goals>
|
||||||
<goal>prepare-agent</goal>
|
<goal>prepare-agent</goal>
|
||||||
</goals>
|
</goals>
|
||||||
@ -145,6 +158,7 @@
|
|||||||
<execution>
|
<execution>
|
||||||
<id>report</id>
|
<id>report</id>
|
||||||
<phase>test</phase>
|
<phase>test</phase>
|
||||||
|
|
||||||
<goals>
|
<goals>
|
||||||
<goal>report</goal>
|
<goal>report</goal>
|
||||||
</goals>
|
</goals>
|
||||||
@ -159,8 +173,7 @@
|
|||||||
<version>3.2.4</version>
|
<version>3.2.4</version>
|
||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
|
<!-- Relocate these to avoid clashes and conflicts -->
|
||||||
<!-- Shade dependencies into the output jar -->
|
|
||||||
<relocations>
|
<relocations>
|
||||||
<relocation>
|
<relocation>
|
||||||
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
||||||
@ -314,7 +327,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.seeseemelk</groupId>
|
<groupId>com.github.seeseemelk</groupId>
|
||||||
<artifactId>MockBukkit-v1.16</artifactId>
|
<artifactId>MockBukkit-v1.16</artifactId>
|
||||||
<version>0.18.0</version>
|
<version>0.20.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -328,7 +341,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>3.6.28</version>
|
<version>3.7.0</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
@ -336,7 +349,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TheBusyBiscuit</groupId>
|
<groupId>com.github.TheBusyBiscuit</groupId>
|
||||||
<artifactId>CS-CoreLib2</artifactId>
|
<artifactId>CS-CoreLib2</artifactId>
|
||||||
<version>0.27.4</version>
|
<version>0.29.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -348,7 +361,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.konghq</groupId>
|
<groupId>com.konghq</groupId>
|
||||||
<artifactId>unirest-java</artifactId>
|
<artifactId>unirest-java</artifactId>
|
||||||
<version>3.11.09</version>
|
<version>3.11.10</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -362,7 +375,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldedit</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>worldedit-bukkit</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
<version>7.2.0</version>
|
<version>7.2.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -380,7 +393,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||||
<artifactId>mcMMO</artifactId>
|
<artifactId>mcMMO</artifactId>
|
||||||
<version>2.1.161</version>
|
<version>2.1.171</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
@ -397,6 +410,13 @@
|
|||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-legacy</artifactId>
|
<artifactId>worldguard-legacy</artifactId>
|
||||||
</exclusion>
|
</exclusion>
|
||||||
|
<exclusion>
|
||||||
|
<!-- We do not want to use the wrong TextComponents by -->
|
||||||
|
<!-- accident. If we use adventure, then we will add -->
|
||||||
|
<!-- it ourselves. -->
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>*</artifactId>
|
||||||
|
</exclusion>
|
||||||
</exclusions>
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -422,7 +442,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.LoneDev6</groupId>
|
<groupId>com.github.LoneDev6</groupId>
|
||||||
<artifactId>itemsadder-api</artifactId>
|
<artifactId>itemsadder-api</artifactId>
|
||||||
<version>0.1.2</version>
|
<version>2.1.25</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -35,6 +35,9 @@ import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
|||||||
* an {@link ErrorReport} instead.
|
* an {@link ErrorReport} instead.
|
||||||
* Error reports get saved in the plugin folder.
|
* Error reports get saved in the plugin folder.
|
||||||
*
|
*
|
||||||
|
* @param <T>
|
||||||
|
* The type of {@link Throwable} which has spawned this {@link ErrorReport}
|
||||||
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -222,6 +225,16 @@ public class ErrorReport<T extends Throwable> {
|
|||||||
return newFile;
|
return newFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This helper method wraps the given {@link Runnable} into a try-catch block.
|
||||||
|
* When an {@link Exception} occurs, a new {@link ErrorReport} will be generated using
|
||||||
|
* the provided {@link Function}.
|
||||||
|
*
|
||||||
|
* @param function
|
||||||
|
* The {@link Function} to generate a new {@link ErrorReport}
|
||||||
|
* @param runnable
|
||||||
|
* The code to execute
|
||||||
|
*/
|
||||||
public static void tryCatch(@Nonnull Function<Exception, ErrorReport<Exception>> function, @Nonnull Runnable runnable) {
|
public static void tryCatch(@Nonnull Function<Exception, ErrorReport<Exception>> function, @Nonnull Runnable runnable) {
|
||||||
try {
|
try {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
@ -6,6 +6,7 @@ import org.apache.commons.lang.Validate;
|
|||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This enum holds all versions of Minecraft that we currently support.
|
* This enum holds all versions of Minecraft that we currently support.
|
||||||
@ -21,19 +22,19 @@ public enum MinecraftVersion {
|
|||||||
* This constant represents Minecraft (Java Edition) Version 1.14
|
* This constant represents Minecraft (Java Edition) Version 1.14
|
||||||
* (The "Village & Pillage" Update)
|
* (The "Village & Pillage" Update)
|
||||||
*/
|
*/
|
||||||
MINECRAFT_1_14("1.14.x"),
|
MINECRAFT_1_14(14, "1.14.x"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constant represents Minecraft (Java Edition) Version 1.15
|
* This constant represents Minecraft (Java Edition) Version 1.15
|
||||||
* (The "Buzzy Bees" Update)
|
* (The "Buzzy Bees" Update)
|
||||||
*/
|
*/
|
||||||
MINECRAFT_1_15("1.15.x"),
|
MINECRAFT_1_15(15, "1.15.x"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constant represents Minecraft (Java Edition) Version 1.16
|
* This constant represents Minecraft (Java Edition) Version 1.16
|
||||||
* (The "Nether Update")
|
* (The "Nether Update")
|
||||||
*/
|
*/
|
||||||
MINECRAFT_1_16("1.16.x"),
|
MINECRAFT_1_16(16, "1.16.x"),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constant represents an exceptional state in which we were unable
|
* This constant represents an exceptional state in which we were unable
|
||||||
@ -51,18 +52,22 @@ public enum MinecraftVersion {
|
|||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final boolean virtual;
|
private final boolean virtual;
|
||||||
private final String prefix;
|
private final int majorVersion;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This constructs a new {@link MinecraftVersion} with the given name.
|
* This constructs a new {@link MinecraftVersion} with the given name.
|
||||||
* This constructor forces the {@link MinecraftVersion} to be real.
|
* This constructor forces the {@link MinecraftVersion} to be real.
|
||||||
* It must be a real version of Minecraft.
|
* It must be a real version of Minecraft.
|
||||||
*
|
*
|
||||||
|
* @param majorVersion
|
||||||
|
* The major version of minecraft as an {@link Integer}
|
||||||
* @param name
|
* @param name
|
||||||
* The display name of this {@link MinecraftVersion}
|
* The display name of this {@link MinecraftVersion}
|
||||||
*/
|
*/
|
||||||
MinecraftVersion(@Nonnull String name) {
|
MinecraftVersion(int majorVersion, @Nonnull String name) {
|
||||||
this(name, false);
|
this.name = name;
|
||||||
|
this.majorVersion = majorVersion;
|
||||||
|
this.virtual = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,8 +82,8 @@ public enum MinecraftVersion {
|
|||||||
*/
|
*/
|
||||||
MinecraftVersion(@Nonnull String name, boolean virtual) {
|
MinecraftVersion(@Nonnull String name, boolean virtual) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.majorVersion = 0;
|
||||||
this.virtual = virtual;
|
this.virtual = virtual;
|
||||||
this.prefix = name().replace("MINECRAFT_", "v") + '_';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,18 +110,21 @@ public enum MinecraftVersion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method checks whether the given version matches with this
|
* This tests if the given minecraft version number matches with this
|
||||||
* {@link MinecraftVersion}.
|
* {@link MinecraftVersion}.
|
||||||
|
* <p>
|
||||||
|
* You can obtain the version number by doing {@link PaperLib#getMinecraftVersion()}.
|
||||||
|
* It is equivalent to the "major" version
|
||||||
|
* <p>
|
||||||
|
* Example: {@literal "1.13"} returns {@literal 13}
|
||||||
*
|
*
|
||||||
* @param version
|
* @param minecraftVersion
|
||||||
* The version to compare
|
* The {@link Integer} version to match
|
||||||
*
|
*
|
||||||
* @return Whether the version matches with this one
|
* @return Whether this {@link MinecraftVersion} matches the specified version id
|
||||||
*/
|
*/
|
||||||
public boolean matches(@Nonnull String version) {
|
public boolean isMinecraftVersion(int minecraftVersion) {
|
||||||
Validate.notNull(version, "The input version must not be null!");
|
return !isVirtual() && this.majorVersion == minecraftVersion;
|
||||||
|
|
||||||
return version.startsWith(prefix);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,21 +1,15 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.api;
|
package io.github.thebusybiscuit.slimefun4.api;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -106,16 +100,4 @@ public interface SlimefunAddon {
|
|||||||
return description.getDepend().contains(dependency) || description.getSoftDepend().contains(dependency);
|
return description.getDepend().contains(dependency) || description.getSoftDepend().contains(dependency);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This returns a {@link Collection} holding every {@link Category} that can be directly
|
|
||||||
* linked to this {@link SlimefunAddon} based on its {@link NamespacedKey}.
|
|
||||||
*
|
|
||||||
* @return A {@link Collection} of every {@link Category} from this addon
|
|
||||||
*/
|
|
||||||
@Nonnull
|
|
||||||
default Collection<Category> getCategories() {
|
|
||||||
String namespace = getJavaPlugin().getName().toLowerCase(Locale.ROOT);
|
|
||||||
return SlimefunPlugin.getRegistry().getCategories().stream().filter(cat -> cat.getKey().getNamespace().equals(namespace)).collect(Collectors.toList());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,10 @@ public class AncientAltarCraftEvent extends PlayerEvent implements Cancellable {
|
|||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param block
|
|
||||||
* The altar {@link Block}
|
|
||||||
* @param output
|
* @param output
|
||||||
* The {@link ItemStack} that would be dropped by the ritual
|
* The {@link ItemStack} that would be dropped by the ritual
|
||||||
|
* @param block
|
||||||
|
* The altar {@link Block}
|
||||||
* @param player
|
* @param player
|
||||||
* The {@link Player} that started the ritual.
|
* The {@link Player} that started the ritual.
|
||||||
*/
|
*/
|
||||||
|
@ -0,0 +1,122 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
|
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 io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInstance;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
* <p>
|
||||||
|
* The {@link Event} will still be fired for non-harvestable blocks.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class AndroidFarmEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final Block block;
|
||||||
|
private final AndroidInstance android;
|
||||||
|
private final boolean isAdvanced;
|
||||||
|
private ItemStack drop;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param block
|
||||||
|
* The harvested {@link Block}
|
||||||
|
* @param android
|
||||||
|
* The {@link AndroidInstance} that triggered this {@link Event}
|
||||||
|
* @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) {
|
||||||
|
this.block = block;
|
||||||
|
this.android = android;
|
||||||
|
this.isAdvanced = isAdvanced;
|
||||||
|
this.drop = drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the mined {@link Block}
|
||||||
|
*
|
||||||
|
* @return the mined {@link Block}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Block getBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the harvested item or null.
|
||||||
|
*
|
||||||
|
* @return The harvested item or null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public ItemStack getDrop() {
|
||||||
|
return drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this was invoked via an advanced farming action
|
||||||
|
*
|
||||||
|
* @return Whether it is advanced
|
||||||
|
*/
|
||||||
|
public boolean isAdvanced() {
|
||||||
|
return isAdvanced;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will set the {@link ItemStack} result.
|
||||||
|
*
|
||||||
|
* @param drop
|
||||||
|
* The result or null
|
||||||
|
*/
|
||||||
|
public void setDrop(@Nullable ItemStack drop) {
|
||||||
|
this.drop = drop;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the {@link AndroidInstance} who
|
||||||
|
* triggered this {@link Event}
|
||||||
|
*
|
||||||
|
* @return the involved {@link AndroidInstance}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public AndroidInstance getAndroid() {
|
||||||
|
return android;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
cancelled = cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return getHandlerList();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -3,16 +3,16 @@ package io.github.thebusybiscuit.slimefun4.api.events;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}.
|
* This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}.
|
||||||
@ -21,8 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefu
|
|||||||
*
|
*
|
||||||
* @author uiytt
|
* @author uiytt
|
||||||
*
|
*
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PlayerPreResearchEvent extends Event implements Cancellable {
|
public class PlayerPreResearchEvent extends Event implements Cancellable {
|
||||||
|
@ -16,7 +16,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.data.ComputedOptional;
|
import io.github.thebusybiscuit.cscorelib2.data.TriStateOptional;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
|
||||||
@ -46,8 +46,8 @@ public class PlayerRightClickEvent extends PlayerEvent {
|
|||||||
private final EquipmentSlot hand;
|
private final EquipmentSlot hand;
|
||||||
private final BlockFace face;
|
private final BlockFace face;
|
||||||
|
|
||||||
private ComputedOptional<SlimefunItem> slimefunItem = ComputedOptional.createNew();
|
private TriStateOptional<SlimefunItem> slimefunItem = TriStateOptional.createNew();
|
||||||
private ComputedOptional<SlimefunItem> slimefunBlock = ComputedOptional.createNew();
|
private TriStateOptional<SlimefunItem> slimefunBlock = TriStateOptional.createNew();
|
||||||
|
|
||||||
private Result itemResult;
|
private Result itemResult;
|
||||||
private Result blockResult;
|
private Result blockResult;
|
||||||
@ -127,7 +127,7 @@ public class PlayerRightClickEvent extends PlayerEvent {
|
|||||||
if (itemStack.isPresent()) {
|
if (itemStack.isPresent()) {
|
||||||
slimefunItem.compute(SlimefunItem.getByItem(itemStack.get()));
|
slimefunItem.compute(SlimefunItem.getByItem(itemStack.get()));
|
||||||
} else {
|
} else {
|
||||||
slimefunItem = ComputedOptional.empty();
|
slimefunItem = TriStateOptional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,7 +140,7 @@ public class PlayerRightClickEvent extends PlayerEvent {
|
|||||||
if (clickedBlock.isPresent()) {
|
if (clickedBlock.isPresent()) {
|
||||||
slimefunBlock.compute(BlockStorage.check(clickedBlock.get()));
|
slimefunBlock.compute(BlockStorage.check(clickedBlock.get()));
|
||||||
} else {
|
} else {
|
||||||
slimefunBlock = ComputedOptional.empty();
|
slimefunBlock = TriStateOptional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,14 +9,14 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
|
* This {@link Event} is called whenever a {@link Player} tries to open the Slimefun Guide book.
|
||||||
*
|
*
|
||||||
* @author Linox
|
* @author Linox
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideLayout
|
* @see SlimefunGuideMode
|
||||||
*/
|
*/
|
||||||
public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
@ -24,10 +24,10 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private final ItemStack guide;
|
private final ItemStack guide;
|
||||||
private SlimefunGuideLayout layout;
|
private SlimefunGuideMode layout;
|
||||||
private boolean cancelled;
|
private boolean cancelled;
|
||||||
|
|
||||||
public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideLayout layout) {
|
public SlimefunGuideOpenEvent(@Nonnull Player p, @Nonnull ItemStack guide, @Nonnull SlimefunGuideMode layout) {
|
||||||
Validate.notNull(p, "The Player cannot be null");
|
Validate.notNull(p, "The Player cannot be null");
|
||||||
Validate.notNull(guide, "Guide cannot be null");
|
Validate.notNull(guide, "Guide cannot be null");
|
||||||
Validate.notNull(layout, "Layout cannot be null");
|
Validate.notNull(layout, "Layout cannot be null");
|
||||||
@ -59,23 +59,23 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the {@link SlimefunGuideLayout} of the Slimefun Guide
|
* This returns the {@link SlimefunGuideMode} of the Slimefun Guide
|
||||||
* that {@link Player} tries to open.
|
* that {@link Player} tries to open.
|
||||||
*
|
*
|
||||||
* @return The {@link SlimefunGuideLayout}
|
* @return The {@link SlimefunGuideMode}
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public SlimefunGuideLayout getGuideLayout() {
|
public SlimefunGuideMode getGuideLayout() {
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Changes the {@link SlimefunGuideLayout} that was tried to be opened with.
|
* Changes the {@link SlimefunGuideMode} that was tried to be opened with.
|
||||||
*
|
*
|
||||||
* @param layout
|
* @param layout
|
||||||
* The new {@link SlimefunGuideLayout}
|
* The new {@link SlimefunGuideMode}
|
||||||
*/
|
*/
|
||||||
public void setGuideLayout(@Nonnull SlimefunGuideLayout layout) {
|
public void setGuideLayout(@Nonnull SlimefunGuideMode layout) {
|
||||||
Validate.notNull(layout, "You must specify a layout that is not-null!");
|
Validate.notNull(layout, "You must specify a layout that is not-null!");
|
||||||
this.layout = layout;
|
this.layout = layout;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager;
|
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager;
|
||||||
@ -34,6 +33,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitte
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
@ -157,7 +157,7 @@ public class GPSNetwork {
|
|||||||
if (sfi instanceof GPSTransmitter) {
|
if (sfi instanceof GPSTransmitter) {
|
||||||
int slot = inventory[index];
|
int slot = inventory[index];
|
||||||
|
|
||||||
menu.addItem(slot, new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + DoubleHandler.fixDouble(1000D / l.getY()) + "ms"));
|
menu.addItem(slot, new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
|
||||||
menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler());
|
menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler());
|
||||||
|
|
||||||
index++;
|
index++;
|
||||||
|
@ -20,11 +20,11 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ public final class TeleportationManager {
|
|||||||
|
|
||||||
int slot = teleporterInventory[index];
|
int slot = teleporterInventory[index];
|
||||||
Location l = waypoint.getLocation();
|
Location l = waypoint.getLocation();
|
||||||
double time = DoubleHandler.fixDouble(0.5 * getTeleportationTime(complexity, source, l));
|
double time = NumberUtils.reparseDouble(0.5 * getTeleportationTime(complexity, source, l));
|
||||||
|
|
||||||
String[] lore = { "", "&8\u21E8 &7" + SlimefunPlugin.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" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s", "", "&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip") };
|
String[] lore = { "", "&8\u21E8 &7" + SlimefunPlugin.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" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s", "", "&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip") };
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ import org.apache.commons.lang.Validate;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a Setting for a {@link SlimefunItem} that can be modified via
|
* This class represents a Setting for a {@link SlimefunItem} that can be modified via
|
||||||
@ -152,19 +151,19 @@ public class ItemSetting<T> {
|
|||||||
if (validateInput(newValue)) {
|
if (validateInput(newValue)) {
|
||||||
this.value = newValue;
|
this.value = newValue;
|
||||||
} else {
|
} else {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
|
SlimefunPlugin.logger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
|
||||||
Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
|
SlimefunPlugin.logger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
|
||||||
Slimefun.getLogger().log(Level.WARNING, "{0} is not a valid input!", configuredValue);
|
SlimefunPlugin.logger().log(Level.WARNING, "{0} is not a valid input!", configuredValue);
|
||||||
Slimefun.getLogger().log(Level.WARNING, getErrorMessage());
|
SlimefunPlugin.logger().log(Level.WARNING, getErrorMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.value = defaultValue;
|
this.value = defaultValue;
|
||||||
String found = configuredValue == null ? "null" : configuredValue.getClass().getSimpleName();
|
String found = configuredValue == null ? "null" : configuredValue.getClass().getSimpleName();
|
||||||
|
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
|
SlimefunPlugin.logger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Please only use settings that are valid.");
|
SlimefunPlugin.logger().log(Level.WARNING, "Please only use settings that are valid.");
|
||||||
Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
|
SlimefunPlugin.logger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Expected \"{0}\" but found: \"{1}\"", new Object[] { defaultValue.getClass().getSimpleName(), found });
|
SlimefunPlugin.logger().log(Level.WARNING, "Expected \"{0}\" but found: \"{1}\"", new Object[] { defaultValue.getClass().getSimpleName(), found });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@ import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
|||||||
* This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be
|
* This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be
|
||||||
* used for {@link ItemSetting} validation.
|
* used for {@link ItemSetting} validation.
|
||||||
*
|
*
|
||||||
|
* @param <T>
|
||||||
|
* The {@link Enum} type
|
||||||
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see ItemSetting
|
* @see ItemSetting
|
||||||
@ -41,6 +44,7 @@ public class EnumSetting<T extends Enum<T>> extends ItemSetting<String> {
|
|||||||
*
|
*
|
||||||
* @return An array of allowed {@link Enum} constants
|
* @return An array of allowed {@link Enum} constants
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public T[] getAllowedValues() {
|
public T[] getAllowedValues() {
|
||||||
return enumClass.getEnumConstants();
|
return enumClass.getEnumConstants();
|
||||||
}
|
}
|
||||||
@ -50,6 +54,7 @@ public class EnumSetting<T extends Enum<T>> extends ItemSetting<String> {
|
|||||||
*
|
*
|
||||||
* @return The value as an {@link Enum} constant
|
* @return The value as an {@link Enum} constant
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public T getAsEnumConstant() {
|
public T getAsEnumConstant() {
|
||||||
return Enum.valueOf(enumClass, getValue());
|
return Enum.valueOf(enumClass, getValue());
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that can store a Player's {@link Research} progress for caching purposes.
|
* A class that can store a Player's {@link Research} progress for caching purposes.
|
||||||
@ -96,7 +95,7 @@ public final class PlayerProfile {
|
|||||||
waypoints.add(new Waypoint(this, key, loc, waypointName));
|
waypoints.add(new Waypoint(this, key, loc, waypointName));
|
||||||
}
|
}
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, x, () -> "Could not load Waypoint \"" + key + "\" for Player \"" + p.getName() + '"');
|
SlimefunPlugin.logger().log(Level.WARNING, x, () -> "Could not load Waypoint \"" + key + "\" for Player \"" + p.getName() + '"');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
@ -25,12 +26,12 @@ import io.github.thebusybiscuit.cscorelib2.config.Config;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunBlockHandler;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
@ -71,12 +72,16 @@ public final class SlimefunRegistry {
|
|||||||
private final Set<SlimefunItem> radioactive = new HashSet<>();
|
private final Set<SlimefunItem> radioactive = new HashSet<>();
|
||||||
private final Set<ItemStack> barterDrops = new HashSet<>();
|
private final Set<ItemStack> barterDrops = new HashSet<>();
|
||||||
|
|
||||||
|
private NamespacedKey soulboundKey;
|
||||||
|
private NamespacedKey itemChargeKey;
|
||||||
|
private NamespacedKey guideKey;
|
||||||
|
|
||||||
private final KeyMap<GEOResource> geoResources = new KeyMap<>();
|
private final KeyMap<GEOResource> geoResources = new KeyMap<>();
|
||||||
|
|
||||||
private final Map<UUID, PlayerProfile> profiles = new ConcurrentHashMap<>();
|
private final Map<UUID, PlayerProfile> profiles = new ConcurrentHashMap<>();
|
||||||
private final Map<String, BlockStorage> worlds = new ConcurrentHashMap<>();
|
private final Map<String, BlockStorage> worlds = new ConcurrentHashMap<>();
|
||||||
private final Map<String, BlockInfoConfig> chunks = new HashMap<>();
|
private final Map<String, BlockInfoConfig> chunks = new HashMap<>();
|
||||||
private final Map<SlimefunGuideLayout, SlimefunGuideImplementation> layouts = new EnumMap<>(SlimefunGuideLayout.class);
|
private final Map<SlimefunGuideMode, SlimefunGuideImplementation> guides = new EnumMap<>(SlimefunGuideMode.class);
|
||||||
private final Map<EntityType, Set<ItemStack>> mobDrops = new EnumMap<>(EntityType.class);
|
private final Map<EntityType, Set<ItemStack>> mobDrops = new EnumMap<>(EntityType.class);
|
||||||
|
|
||||||
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
private final Map<String, BlockMenuPreset> blockMenuPresets = new HashMap<>();
|
||||||
@ -84,14 +89,17 @@ public final class SlimefunRegistry {
|
|||||||
private final Map<Class<? extends ItemHandler>, Set<ItemHandler>> globalItemHandlers = new HashMap<>();
|
private final Map<Class<? extends ItemHandler>, Set<ItemHandler>> globalItemHandlers = new HashMap<>();
|
||||||
private final Map<String, SlimefunBlockHandler> blockHandlers = new HashMap<>();
|
private final Map<String, SlimefunBlockHandler> blockHandlers = new HashMap<>();
|
||||||
|
|
||||||
public void load(@Nonnull Config cfg) {
|
public void load(@Nonnull SlimefunPlugin plugin, @Nonnull Config cfg) {
|
||||||
|
Validate.notNull(plugin, "The Plugin cannot be null!");
|
||||||
Validate.notNull(cfg, "The Config cannot be null!");
|
Validate.notNull(cfg, "The Config cannot be null!");
|
||||||
|
|
||||||
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
|
soulboundKey = new NamespacedKey(plugin, "soulbound");
|
||||||
|
itemChargeKey = new NamespacedKey(plugin, "item_charge");
|
||||||
|
guideKey = new NamespacedKey(plugin, "slimefun_guide_mode");
|
||||||
|
|
||||||
layouts.put(SlimefunGuideLayout.CHEST, new ChestSlimefunGuide(showVanillaRecipes));
|
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
|
||||||
layouts.put(SlimefunGuideLayout.CHEAT_SHEET, new CheatSheetSlimefunGuide());
|
guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes));
|
||||||
layouts.put(SlimefunGuideLayout.BOOK, new BookSlimefunGuide());
|
guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide());
|
||||||
|
|
||||||
researchRanks.addAll(cfg.getStringList("research-ranks"));
|
researchRanks.addAll(cfg.getStringList("research-ranks"));
|
||||||
|
|
||||||
@ -132,6 +140,7 @@ public final class SlimefunRegistry {
|
|||||||
automaticallyLoadItems = mode;
|
automaticallyLoadItems = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public List<Category> getCategories() {
|
public List<Category> getCategories() {
|
||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
@ -141,6 +150,7 @@ public final class SlimefunRegistry {
|
|||||||
*
|
*
|
||||||
* @return A {@link List} containing every {@link SlimefunItem}
|
* @return A {@link List} containing every {@link SlimefunItem}
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public List<SlimefunItem> getAllSlimefunItems() {
|
public List<SlimefunItem> getAllSlimefunItems() {
|
||||||
return slimefunItems;
|
return slimefunItems;
|
||||||
}
|
}
|
||||||
@ -150,18 +160,22 @@ public final class SlimefunRegistry {
|
|||||||
*
|
*
|
||||||
* @return A {@link List} containing every enabled {@link SlimefunItem}
|
* @return A {@link List} containing every enabled {@link SlimefunItem}
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public List<SlimefunItem> getEnabledSlimefunItems() {
|
public List<SlimefunItem> getEnabledSlimefunItems() {
|
||||||
return enabledItems;
|
return enabledItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public List<Research> getResearches() {
|
public List<Research> getResearches() {
|
||||||
return researches;
|
return researches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Set<UUID> getCurrentlyResearchingPlayers() {
|
public Set<UUID> getCurrentlyResearchingPlayers() {
|
||||||
return researchingPlayers;
|
return researchingPlayers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public List<String> getResearchRanks() {
|
public List<String> getResearchRanks() {
|
||||||
return researchRanks;
|
return researchRanks;
|
||||||
}
|
}
|
||||||
@ -186,12 +200,31 @@ public final class SlimefunRegistry {
|
|||||||
return researchFireworks;
|
return researchFireworks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public List<MultiBlock> getMultiBlocks() {
|
public List<MultiBlock> getMultiBlocks() {
|
||||||
return multiblocks;
|
return multiblocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SlimefunGuideImplementation getGuideLayout(SlimefunGuideLayout layout) {
|
/**
|
||||||
return layouts.get(layout);
|
* This returns the corresponding {@link SlimefunGuideImplementation} for a certain
|
||||||
|
* {@link SlimefunGuideMode}.
|
||||||
|
*
|
||||||
|
* @param mode
|
||||||
|
* The {@link SlimefunGuideMode}
|
||||||
|
*
|
||||||
|
* @return The corresponding {@link SlimefunGuideImplementation}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public SlimefunGuideImplementation getSlimefunGuide(@Nonnull SlimefunGuideMode mode) {
|
||||||
|
Validate.notNull(mode, "The Guide mode cannot be null");
|
||||||
|
|
||||||
|
SlimefunGuideImplementation guide = guides.get(mode);
|
||||||
|
|
||||||
|
if (guide == null) {
|
||||||
|
throw new IllegalStateException("Slimefun Guide '" + mode + "' has no registered implementation.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return guide;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,6 +233,7 @@ public final class SlimefunRegistry {
|
|||||||
*
|
*
|
||||||
* @return The {@link Map} of custom mob drops
|
* @return The {@link Map} of custom mob drops
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public Map<EntityType, Set<ItemStack>> getMobDrops() {
|
public Map<EntityType, Set<ItemStack>> getMobDrops() {
|
||||||
return mobDrops;
|
return mobDrops;
|
||||||
}
|
}
|
||||||
@ -210,50 +244,62 @@ public final class SlimefunRegistry {
|
|||||||
*
|
*
|
||||||
* @return A {@link Set} of bartering drops
|
* @return A {@link Set} of bartering drops
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public Set<ItemStack> getBarteringDrops() {
|
public Set<ItemStack> getBarteringDrops() {
|
||||||
return barterDrops;
|
return barterDrops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Set<SlimefunItem> getRadioactiveItems() {
|
public Set<SlimefunItem> getRadioactiveItems() {
|
||||||
return radioactive;
|
return radioactive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Set<String> getTickerBlocks() {
|
public Set<String> getTickerBlocks() {
|
||||||
return tickers;
|
return tickers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<String, SlimefunItem> getSlimefunItemIds() {
|
public Map<String, SlimefunItem> getSlimefunItemIds() {
|
||||||
return slimefunIds;
|
return slimefunIds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<String, BlockMenuPreset> getMenuPresets() {
|
public Map<String, BlockMenuPreset> getMenuPresets() {
|
||||||
return blockMenuPresets;
|
return blockMenuPresets;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<String, UniversalBlockMenu> getUniversalInventories() {
|
public Map<String, UniversalBlockMenu> getUniversalInventories() {
|
||||||
return universalInventories;
|
return universalInventories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<UUID, PlayerProfile> getPlayerProfiles() {
|
public Map<UUID, PlayerProfile> getPlayerProfiles() {
|
||||||
return profiles;
|
return profiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<Class<? extends ItemHandler>, Set<ItemHandler>> getPublicItemHandlers() {
|
public Map<Class<? extends ItemHandler>, Set<ItemHandler>> getPublicItemHandlers() {
|
||||||
return globalItemHandlers;
|
return globalItemHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<String, SlimefunBlockHandler> getBlockHandlers() {
|
public Map<String, SlimefunBlockHandler> getBlockHandlers() {
|
||||||
return blockHandlers;
|
return blockHandlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<String, BlockStorage> getWorlds() {
|
public Map<String, BlockStorage> getWorlds() {
|
||||||
return worlds;
|
return worlds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public Map<String, BlockInfoConfig> getChunks() {
|
public Map<String, BlockInfoConfig> getChunks() {
|
||||||
return chunks;
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public KeyMap<GEOResource> getGEOResources() {
|
public KeyMap<GEOResource> getGEOResources() {
|
||||||
return geoResources;
|
return geoResources;
|
||||||
}
|
}
|
||||||
@ -262,4 +308,19 @@ public final class SlimefunRegistry {
|
|||||||
return logDuplicateBlockEntries;
|
return logDuplicateBlockEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public NamespacedKey getSoulboundDataKey() {
|
||||||
|
return soulboundKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public NamespacedKey getItemChargeDataKey() {
|
||||||
|
return itemChargeKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public NamespacedKey getGuideDataKey() {
|
||||||
|
return guideKey;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||||
|
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implement this interface for any {@link AContainer} to prevent
|
||||||
|
* that {@link AContainer} from being hopperable.
|
||||||
|
*
|
||||||
|
* @author CURVX
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface NotHopperable extends ItemAttribute {
|
||||||
|
|
||||||
|
}
|
@ -28,7 +28,6 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
*/
|
*/
|
||||||
final class RechargeableHelper {
|
final class RechargeableHelper {
|
||||||
|
|
||||||
private static final NamespacedKey CHARGE_KEY = new NamespacedKey(SlimefunPlugin.instance(), "item_charge");
|
|
||||||
private static final String LORE_PREFIX = ChatColors.color("&8\u21E8 &e\u26A1 &7");
|
private static final String LORE_PREFIX = ChatColors.color("&8\u21E8 &e\u26A1 &7");
|
||||||
private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9.]+ / [0-9.]+ J");
|
private static final Pattern REGEX = Pattern.compile(ChatColors.color("(&c&o)?" + LORE_PREFIX) + "[0-9.]+ / [0-9.]+ J");
|
||||||
|
|
||||||
@ -38,7 +37,8 @@ final class RechargeableHelper {
|
|||||||
BigDecimal decimal = BigDecimal.valueOf(charge).setScale(2, RoundingMode.HALF_UP);
|
BigDecimal decimal = BigDecimal.valueOf(charge).setScale(2, RoundingMode.HALF_UP);
|
||||||
float value = decimal.floatValue();
|
float value = decimal.floatValue();
|
||||||
|
|
||||||
meta.getPersistentDataContainer().set(CHARGE_KEY, PersistentDataType.FLOAT, value);
|
NamespacedKey key = SlimefunPlugin.getRegistry().getItemChargeDataKey();
|
||||||
|
meta.getPersistentDataContainer().set(key, PersistentDataType.FLOAT, value);
|
||||||
|
|
||||||
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
|
||||||
for (int i = 0; i < lore.size(); i++) {
|
for (int i = 0; i < lore.size(); i++) {
|
||||||
@ -56,7 +56,8 @@ final class RechargeableHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static float getCharge(@Nonnull ItemMeta meta) {
|
static float getCharge(@Nonnull ItemMeta meta) {
|
||||||
Float value = meta.getPersistentDataContainer().get(CHARGE_KEY, PersistentDataType.FLOAT);
|
NamespacedKey key = SlimefunPlugin.getRegistry().getItemChargeDataKey();
|
||||||
|
Float value = meta.getPersistentDataContainer().get(key, PersistentDataType.FLOAT);
|
||||||
|
|
||||||
// If persistent data is available, we just return this value
|
// If persistent data is available, we just return this value
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
|
@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
@ -45,12 +45,12 @@ public abstract class FlexCategory extends Category {
|
|||||||
* @param profile
|
* @param profile
|
||||||
* The {@link PlayerProfile} of the {@link Player}
|
* The {@link PlayerProfile} of the {@link Player}
|
||||||
* @param layout
|
* @param layout
|
||||||
* The {@link SlimefunGuideLayout} in which this {@link FlexCategory} is viewed
|
* The {@link SlimefunGuideMode} in which this {@link FlexCategory} is viewed
|
||||||
*
|
*
|
||||||
* @return Whether to display this {@link FlexCategory}
|
* @return Whether to display this {@link FlexCategory}
|
||||||
*/
|
*/
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideLayout layout);
|
public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called when a {@link Player} opens this {@link FlexCategory}.
|
* This method is called when a {@link Player} opens this {@link FlexCategory}.
|
||||||
@ -62,13 +62,13 @@ public abstract class FlexCategory extends Category {
|
|||||||
* @param profile
|
* @param profile
|
||||||
* The corresponding {@link PlayerProfile} for that {@link Player}
|
* The corresponding {@link PlayerProfile} for that {@link Player}
|
||||||
* @param layout
|
* @param layout
|
||||||
* The current {@link SlimefunGuideLayout}
|
* The current {@link SlimefunGuideMode}
|
||||||
*/
|
*/
|
||||||
public abstract void open(Player p, PlayerProfile profile, SlimefunGuideLayout layout);
|
public abstract void open(Player p, PlayerProfile profile, SlimefunGuideMode layout);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final boolean isHidden(@Nonnull Player p) {
|
public final boolean isHidden(@Nonnull Player p) {
|
||||||
/**
|
/*
|
||||||
* We can stop this method right here.
|
* We can stop this method right here.
|
||||||
* We provide a custom method with more parameters for this.
|
* We provide a custom method with more parameters for this.
|
||||||
* See isVisible(...)
|
* See isVisible(...)
|
||||||
|
@ -14,11 +14,11 @@ import org.bukkit.NamespacedKey;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a {@link Category} that cannot be opened until the parent category/categories
|
* Represents a {@link Category} that cannot be opened until the parent category/categories
|
||||||
@ -76,8 +76,8 @@ public class LockedCategory extends Category {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void register() {
|
public void register(@Nonnull SlimefunAddon addon) {
|
||||||
super.register();
|
super.register(addon);
|
||||||
|
|
||||||
List<NamespacedKey> namespacedKeys = new ArrayList<>();
|
List<NamespacedKey> namespacedKeys = new ArrayList<>();
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public class LockedCategory extends Category {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (NamespacedKey key : namespacedKeys) {
|
for (NamespacedKey key : namespacedKeys) {
|
||||||
Slimefun.getLogger().log(Level.INFO, "Parent \"{0}\" for Category \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() });
|
SlimefunPlugin.logger().log(Level.INFO, "Parent \"{0}\" for Category \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.bukkit.entity.Player;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
class GuideCommand extends SubCommand {
|
class GuideCommand extends SubCommand {
|
||||||
@ -19,7 +19,7 @@ class GuideCommand extends SubCommand {
|
|||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(CommandSender sender, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (sender.hasPermission("slimefun.command.guide")) {
|
if (sender.hasPermission("slimefun.command.guide")) {
|
||||||
SlimefunGuideLayout design = SlimefunGuide.getDefaultLayout();
|
SlimefunGuideMode design = SlimefunGuide.getDefaultMode();
|
||||||
((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone());
|
((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone());
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
class OpenGuideCommand extends SubCommand {
|
class OpenGuideCommand extends SubCommand {
|
||||||
@ -16,11 +18,11 @@ class OpenGuideCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(CommandSender sender, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
if (sender.hasPermission("slimefun.command.open_guide")) {
|
if (sender.hasPermission("slimefun.command.open_guide")) {
|
||||||
boolean book = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book");
|
SlimefunGuide.openGuide((Player) sender, SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
SlimefunGuide.openGuide((Player) sender, book ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST);
|
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
class SearchCommand extends SubCommand {
|
class SearchCommand extends SubCommand {
|
||||||
@ -23,7 +24,7 @@ class SearchCommand extends SubCommand {
|
|||||||
if (sender.hasPermission("slimefun.command.search")) {
|
if (sender.hasPermission("slimefun.command.search")) {
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
||||||
PlayerProfile.get((Player) sender, profile -> SlimefunGuide.openSearch(profile, query, true, true));
|
PlayerProfile.get((Player) sender, profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true));
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search <SearchTerm>"));
|
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search <SearchTerm>"));
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,97 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
||||||
|
|
||||||
|
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.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
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.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
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.inspectors.ConsolePerformanceInspector;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
class TimingsCommand extends SubCommand {
|
class TimingsCommand extends SubCommand {
|
||||||
|
|
||||||
|
private static final String FLAG_PREFIX = "--";
|
||||||
|
private final Set<String> flags = new HashSet<>(Arrays.asList("verbose"));
|
||||||
|
|
||||||
TimingsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
TimingsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||||
super(plugin, cmd, "timings", false);
|
super(plugin, cmd, "timings", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected String getDescription() {
|
||||||
|
return "commands.timings.description";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(CommandSender sender, String[] args) {
|
||||||
if (sender.hasPermission("slimefun.command.timings") || sender instanceof ConsoleCommandSender) {
|
if (sender.hasPermission("slimefun.command.timings") || sender instanceof ConsoleCommandSender) {
|
||||||
sender.sendMessage("Please wait a second... The results are coming in!");
|
if (hasInvalidFlags(sender, args)) {
|
||||||
SlimefunPlugin.getProfiler().requestSummary(sender);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean verbose = hasFlag(args, "verbose");
|
||||||
|
|
||||||
|
if (verbose && sender instanceof Player) {
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.timings.verbose-player", true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.timings.please-wait", true);
|
||||||
|
|
||||||
|
PerformanceInspector inspector = inspectorOf(sender, verbose);
|
||||||
|
SlimefunPlugin.getProfiler().requestSummary(inspector);
|
||||||
} else {
|
} else {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
private boolean hasInvalidFlags(CommandSender sender, String[] args) {
|
||||||
|
boolean hasInvalidFlags = false;
|
||||||
|
|
||||||
|
// We start at 1 because args[0] will be "timings".
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
String argument = args[i].toLowerCase(Locale.ROOT);
|
||||||
|
|
||||||
|
if (argument.startsWith(FLAG_PREFIX) && !flags.contains(argument.substring(2))) {
|
||||||
|
hasInvalidFlags = true;
|
||||||
|
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hasInvalidFlags;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
|
private boolean hasFlag(String[] args, String flag) {
|
||||||
|
// We start at 1 because args[0] will be "timings".
|
||||||
|
for (int i = 1; i < args.length; i++) {
|
||||||
|
if (args[i].equalsIgnoreCase(FLAG_PREFIX + flag)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
private PerformanceInspector inspectorOf(@Nonnull CommandSender sender, boolean verbose) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
return new PlayerPerformanceInspector((Player) sender);
|
||||||
|
} else {
|
||||||
|
return new ConsolePerformanceInspector(sender, verbose);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -9,7 +10,6 @@ import org.bukkit.command.ConsoleCommandSender;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
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.SlimefunCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
@ -22,14 +22,14 @@ class VersionsCommand extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(CommandSender sender, String[] args) {
|
public void onExecute(@Nonnull CommandSender sender, @Nonnull String[] args) {
|
||||||
if (sender.hasPermission("slimefun.command.versions") || sender instanceof ConsoleCommandSender) {
|
if (sender.hasPermission("slimefun.command.versions") || sender instanceof ConsoleCommandSender) {
|
||||||
// After all these years... Spigot still displays as "CraftBukkit"
|
// After all these years... Spigot still displays as "CraftBukkit"
|
||||||
// so we will just fix this inconsistency for them :)
|
// so we will just fix this inconsistency for them :)
|
||||||
String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName();
|
String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName();
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GRAY + "This Server uses the following setup of Slimefun:");
|
sender.sendMessage(ChatColor.GRAY + "This Server uses the following setup of Slimefun:");
|
||||||
sender.sendMessage(ChatColors.color("&a" + serverSoftware + " &2" + ReflectionUtils.getVersion()));
|
sender.sendMessage(ChatColors.color("&a" + serverSoftware + " &2" + Bukkit.getVersion()));
|
||||||
sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion()));
|
sender.sendMessage(ChatColors.color("&aCS-CoreLib &2v" + SlimefunPlugin.getCSCoreLibVersion()));
|
||||||
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion()));
|
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion()));
|
||||||
|
|
||||||
|
@ -3,15 +3,19 @@ package io.github.thebusybiscuit.slimefun4.core.guide;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
@ -22,36 +26,35 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideImplementation
|
* @see SlimefunGuideImplementation
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public final class SlimefunGuide {
|
public final class SlimefunGuide {
|
||||||
|
|
||||||
private SlimefunGuide() {}
|
private SlimefunGuide() {}
|
||||||
|
|
||||||
public static ItemStack getItem(@Nonnull SlimefunGuideLayout design) {
|
@Nonnull
|
||||||
return SlimefunPlugin.getRegistry().getGuideLayout(design).getItem();
|
public static ItemStack getItem(@Nonnull SlimefunGuideMode design) {
|
||||||
|
return SlimefunPlugin.getRegistry().getSlimefunGuide(design).getItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openCheatMenu(Player p) {
|
public static void openCheatMenu(@Nonnull Player p) {
|
||||||
openMainMenuAsync(p, SlimefunGuideLayout.CHEAT_SHEET, 1);
|
openMainMenuAsync(p, SlimefunGuideMode.CHEAT_MODE, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openGuide(Player p, ItemStack guide) {
|
public static void openGuide(@Nonnull Player p, @Nullable ItemStack guide) {
|
||||||
if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEST), true)) {
|
if (getItem(SlimefunGuideMode.CHEAT_MODE).equals(guide)) {
|
||||||
openGuide(p, SlimefunGuideLayout.CHEST);
|
openGuide(p, SlimefunGuideMode.CHEAT_MODE);
|
||||||
} else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.BOOK), true)) {
|
|
||||||
openGuide(p, SlimefunGuideLayout.BOOK);
|
|
||||||
} else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) {
|
|
||||||
openGuide(p, SlimefunGuideLayout.CHEAT_SHEET);
|
|
||||||
} else {
|
} else {
|
||||||
// When using /sf cheat or /sf open_guide, ItemStack is null.
|
/*
|
||||||
openGuide(p, SlimefunGuideLayout.CHEST);
|
* When using /sf cheat or /sf open_guide the ItemStack is null anyway,
|
||||||
|
* so we don't even need to check here at this point.
|
||||||
|
*/
|
||||||
|
openGuide(p, SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openGuide(Player p, SlimefunGuideLayout layout) {
|
public static void openGuide(@Nonnull Player p, @Nonnull SlimefunGuideMode mode) {
|
||||||
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -60,58 +63,72 @@ public final class SlimefunGuide {
|
|||||||
|
|
||||||
if (optional.isPresent()) {
|
if (optional.isPresent()) {
|
||||||
PlayerProfile profile = optional.get();
|
PlayerProfile profile = optional.get();
|
||||||
SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getGuideLayout(layout);
|
SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getSlimefunGuide(mode);
|
||||||
profile.getGuideHistory().openLastEntry(guide);
|
profile.getGuideHistory().openLastEntry(guide);
|
||||||
} else {
|
} else {
|
||||||
openMainMenuAsync(p, layout, 1);
|
openMainMenuAsync(p, mode, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void openMainMenuAsync(Player player, SlimefunGuideLayout layout, int selectedPage) {
|
@ParametersAreNonnullByDefault
|
||||||
if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, layout, selectedPage)))) {
|
private static void openMainMenuAsync(Player player, SlimefunGuideMode mode, int selectedPage) {
|
||||||
|
if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, mode, selectedPage)))) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide");
|
SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openMainMenu(PlayerProfile profile, SlimefunGuideLayout layout, int selectedPage) {
|
@ParametersAreNonnullByDefault
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(layout).openMainMenu(profile, selectedPage);
|
public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode mode, int selectedPage) {
|
||||||
|
SlimefunPlugin.getRegistry().getSlimefunGuide(mode).openMainMenu(profile, selectedPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideLayout layout, int selectedPage) {
|
@ParametersAreNonnullByDefault
|
||||||
if (category == null) {
|
public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode mode, int selectedPage) {
|
||||||
return;
|
SlimefunPlugin.getRegistry().getSlimefunGuide(mode).openCategory(profile, category, selectedPage);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage);
|
@ParametersAreNonnullByDefault
|
||||||
}
|
public static void openSearch(PlayerProfile profile, String input, SlimefunGuideMode mode, boolean addToHistory) {
|
||||||
|
SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getSlimefunGuide(mode);
|
||||||
public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) {
|
guide.openSearch(profile, input, addToHistory);
|
||||||
SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST);
|
|
||||||
|
|
||||||
if (!survival) {
|
|
||||||
layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET);
|
|
||||||
}
|
|
||||||
|
|
||||||
layout.openSearch(profile, input, addToHistory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) {
|
public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) {
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST).displayItem(profile, item, 0, addToHistory);
|
SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
||||||
SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST).displayItem(profile, item, addToHistory);
|
SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isGuideItem(ItemStack item) {
|
/**
|
||||||
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEST), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.BOOK), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideLayout.CHEAT_SHEET), true);
|
* This method checks if a given {@link ItemStack} is a {@link SlimefunGuide}.
|
||||||
}
|
*
|
||||||
|
* @param item
|
||||||
public static SlimefunGuideLayout getDefaultLayout() {
|
* The {@link ItemStack} to check
|
||||||
if (SlimefunPlugin.getCfg().getBoolean("guide.default-view-book")) {
|
*
|
||||||
return SlimefunGuideLayout.BOOK;
|
* @return Whether this {@link ItemStack} represents a {@link SlimefunGuide}
|
||||||
|
*/
|
||||||
|
public static boolean isGuideItem(@Nullable ItemStack item) {
|
||||||
|
if (item == null || item.getType() != Material.ENCHANTED_BOOK) {
|
||||||
|
return false;
|
||||||
|
} else if (item instanceof SlimefunGuideItem) {
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return SlimefunGuideLayout.CHEST;
|
return SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.SURVIVAL_MODE), true) || SlimefunUtils.isItemSimilar(item, getItem(SlimefunGuideMode.CHEAT_MODE), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the default mode for the Slimefun guide.
|
||||||
|
* Currently this is only {@link SlimefunGuideMode#SURVIVAL_MODE}.
|
||||||
|
*
|
||||||
|
* @return The default {@link SlimefunGuideMode}.
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static SlimefunGuideMode getDefaultMode() {
|
||||||
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.BookSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
@ -22,21 +21,20 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuideLayout
|
* @see SlimefunGuideMode
|
||||||
* @see ChestSlimefunGuide
|
* @see SurvivalSlimefunGuide
|
||||||
* @see BookSlimefunGuide
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface SlimefunGuideImplementation {
|
public interface SlimefunGuideImplementation {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Every {@link SlimefunGuideImplementation} can be associated with a
|
* Every {@link SlimefunGuideImplementation} can be associated with a
|
||||||
* {@link SlimefunGuideLayout}.
|
* {@link SlimefunGuideMode}.
|
||||||
*
|
*
|
||||||
* @return The layout this {@link SlimefunGuideImplementation} represents
|
* @return The mode this {@link SlimefunGuideImplementation} represents
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
SlimefunGuideLayout getLayout();
|
SlimefunGuideMode getMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the {@link ItemStack} representation for this {@link SlimefunGuideImplementation}.
|
* Returns the {@link ItemStack} representation for this {@link SlimefunGuideImplementation}.
|
||||||
@ -48,14 +46,6 @@ public interface SlimefunGuideImplementation {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
ItemStack getItem();
|
ItemStack getItem();
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns whether this {@link SlimefunGuideImplementation} is meant
|
|
||||||
* for Survival Mode.
|
|
||||||
*
|
|
||||||
* @return Whether this is a survival mode implementation
|
|
||||||
*/
|
|
||||||
boolean isSurvivalMode();
|
|
||||||
|
|
||||||
void openMainMenu(PlayerProfile profile, int page);
|
void openMainMenu(PlayerProfile profile, int page);
|
||||||
|
|
||||||
void openCategory(PlayerProfile profile, Category category, int page);
|
void openCategory(PlayerProfile profile, Category category, int page);
|
||||||
|
@ -13,24 +13,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
* @see SlimefunGuideImplementation
|
* @see SlimefunGuideImplementation
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public enum SlimefunGuideLayout {
|
public enum SlimefunGuideMode {
|
||||||
|
|
||||||
/**
|
|
||||||
* This design is a book representation of the {@link SlimefunGuide}
|
|
||||||
*/
|
|
||||||
BOOK,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This design is the standard layout, it uses a {@link ChestMenu}
|
* This design is the standard layout, it uses a {@link ChestMenu}
|
||||||
*/
|
*/
|
||||||
CHEST,
|
SURVIVAL_MODE,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an admin-only design which creates a {@link SlimefunGuide} that allows
|
* This is an admin-only design which creates a {@link SlimefunGuide} that allows
|
||||||
* you to spawn in any {@link SlimefunItem}
|
* you to spawn in any {@link SlimefunItem}
|
||||||
*/
|
*/
|
||||||
CHEAT_SHEET;
|
CHEAT_MODE;
|
||||||
|
|
||||||
public static final SlimefunGuideLayout[] valuesCache = values();
|
|
||||||
|
|
||||||
}
|
}
|
@ -4,6 +4,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
@ -13,35 +16,41 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
|
|
||||||
class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
class GuideModeOption implements SlimefunGuideOption<SlimefunGuideMode> {
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SlimefunAddon getAddon() {
|
public SlimefunAddon getAddon() {
|
||||||
return SlimefunPlugin.instance();
|
return SlimefunPlugin.instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public NamespacedKey getKey() {
|
public NamespacedKey getKey() {
|
||||||
return new NamespacedKey(SlimefunPlugin.instance(), "guide_layout");
|
return new NamespacedKey(SlimefunPlugin.instance(), "guide_layout");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
||||||
Optional<SlimefunGuideLayout> current = getSelectedOption(p, guide);
|
if (!p.hasPermission("slimefun.cheat.items")) {
|
||||||
|
// Only Players with the appropriate permission can access the cheat sheet
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<SlimefunGuideMode> current = getSelectedOption(p, guide);
|
||||||
|
|
||||||
if (current.isPresent()) {
|
if (current.isPresent()) {
|
||||||
SlimefunGuideLayout layout = current.get();
|
SlimefunGuideMode layout = current.get();
|
||||||
ItemStack item = new ItemStack(Material.AIR);
|
ItemStack item = new ItemStack(Material.AIR);
|
||||||
|
|
||||||
if (layout == SlimefunGuideLayout.CHEST) {
|
if (layout == SlimefunGuideMode.SURVIVAL_MODE) {
|
||||||
item.setType(Material.CHEST);
|
item.setType(Material.CHEST);
|
||||||
} else if (layout == SlimefunGuideLayout.BOOK) {
|
|
||||||
item.setType(Material.BOOK);
|
|
||||||
} else {
|
} else {
|
||||||
item.setType(Material.COMMAND_BLOCK);
|
item.setType(Material.COMMAND_BLOCK);
|
||||||
}
|
}
|
||||||
@ -50,12 +59,9 @@ class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
|||||||
meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Design: " + ChatColor.YELLOW + ChatUtils.humanize(layout.name()));
|
meta.setDisplayName(ChatColor.GRAY + "Slimefun Guide Design: " + ChatColor.YELLOW + ChatUtils.humanize(layout.name()));
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add((layout == SlimefunGuideLayout.CHEST ? ChatColor.GREEN : ChatColor.GRAY) + "Chest");
|
lore.add((layout == SlimefunGuideMode.SURVIVAL_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Chest");
|
||||||
lore.add((layout == SlimefunGuideLayout.BOOK ? ChatColor.GREEN : ChatColor.GRAY) + "Book");
|
|
||||||
|
|
||||||
if (p.hasPermission("slimefun.cheat.items")) {
|
lore.add((layout == SlimefunGuideMode.CHEAT_MODE ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
|
||||||
lore.add((layout == SlimefunGuideLayout.CHEAT_SHEET ? ChatColor.GREEN : ChatColor.GRAY) + "Cheat Sheet");
|
|
||||||
}
|
|
||||||
|
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change your layout");
|
lore.add(ChatColor.GRAY + "\u21E8 " + ChatColor.YELLOW + "Click to change your layout");
|
||||||
@ -69,46 +75,43 @@ class GuideLayoutOption implements SlimefunGuideOption<SlimefunGuideLayout> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(Player p, ItemStack guide) {
|
public void onClick(@Nonnull Player p, @Nonnull ItemStack guide) {
|
||||||
Optional<SlimefunGuideLayout> current = getSelectedOption(p, guide);
|
Optional<SlimefunGuideMode> current = getSelectedOption(p, guide);
|
||||||
|
|
||||||
if (current.isPresent()) {
|
if (current.isPresent()) {
|
||||||
SlimefunGuideLayout next = getNextLayout(p, current.get());
|
SlimefunGuideMode next = getNextMode(p, current.get());
|
||||||
setSelectedOption(p, guide, next);
|
setSelectedOption(p, guide, next);
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunGuideSettings.openSettings(p, guide);
|
SlimefunGuideSettings.openSettings(p, guide);
|
||||||
}
|
}
|
||||||
|
|
||||||
private SlimefunGuideLayout getNextLayout(Player p, SlimefunGuideLayout layout) {
|
@Nonnull
|
||||||
|
private SlimefunGuideMode getNextMode(@Nonnull Player p, @Nonnull SlimefunGuideMode mode) {
|
||||||
if (p.hasPermission("slimefun.cheat.items")) {
|
if (p.hasPermission("slimefun.cheat.items")) {
|
||||||
if (layout == SlimefunGuideLayout.CHEST) {
|
if (mode == SlimefunGuideMode.SURVIVAL_MODE) {
|
||||||
return SlimefunGuideLayout.BOOK;
|
return SlimefunGuideMode.CHEAT_MODE;
|
||||||
}
|
|
||||||
|
|
||||||
if (layout == SlimefunGuideLayout.BOOK) {
|
|
||||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return SlimefunGuideLayout.CHEST;
|
|
||||||
} else {
|
} else {
|
||||||
return layout == SlimefunGuideLayout.CHEST ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST;
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
@Override
|
||||||
|
public Optional<SlimefunGuideMode> getSelectedOption(@Nonnull Player p, @Nonnull ItemStack guide) {
|
||||||
|
if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(SlimefunGuideMode.CHEAT_MODE), true, false)) {
|
||||||
|
return Optional.of(SlimefunGuideMode.CHEAT_MODE);
|
||||||
|
} else {
|
||||||
|
return Optional.of(SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<SlimefunGuideLayout> getSelectedOption(Player p, ItemStack guide) {
|
@ParametersAreNonnullByDefault
|
||||||
for (SlimefunGuideLayout layout : SlimefunGuideLayout.valuesCache) {
|
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideMode value) {
|
||||||
if (SlimefunUtils.isItemSimilar(guide, SlimefunGuide.getItem(layout), true, false)) {
|
|
||||||
return Optional.of(layout);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setSelectedOption(Player p, ItemStack guide, SlimefunGuideLayout value) {
|
|
||||||
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
|
guide.setItemMeta(SlimefunGuide.getItem(value).getItemMeta());
|
||||||
}
|
}
|
||||||
|
|
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
@ -39,7 +39,7 @@ public final class SlimefunGuideSettings {
|
|||||||
private static final List<SlimefunGuideOption<?>> options = new ArrayList<>();
|
private static final List<SlimefunGuideOption<?>> options = new ArrayList<>();
|
||||||
|
|
||||||
static {
|
static {
|
||||||
options.add(new GuideLayoutOption());
|
options.add(new GuideModeOption());
|
||||||
options.add(new FireworksOption());
|
options.add(new FireworksOption());
|
||||||
options.add(new PlayerLanguageOption());
|
options.add(new PlayerLanguageOption());
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ public final class SlimefunGuideSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
|
private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
|
||||||
menu.addItem(0, new CustomItem(SlimefunGuide.getItem(SlimefunGuideLayout.CHEST), "&e\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")), (pl, slot, item, action) -> {
|
menu.addItem(0, new CustomItem(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE), "&e\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")), (pl, slot, item, action) -> {
|
||||||
SlimefunGuide.openGuide(pl, guide);
|
SlimefunGuide.openGuide(pl, guide);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -141,7 +141,7 @@ public final class SlimefunGuideSettings {
|
|||||||
for (SlimefunGuideOption<?> option : options) {
|
for (SlimefunGuideOption<?> option : options) {
|
||||||
if (option instanceof FireworksOption) {
|
if (option instanceof FireworksOption) {
|
||||||
FireworksOption fireworks = (FireworksOption) option;
|
FireworksOption fireworks = (FireworksOption) option;
|
||||||
return fireworks.getSelectedOption(p, SlimefunGuide.getItem(SlimefunGuideLayout.CHEST)).orElse(true);
|
return fireworks.getSelectedOption(p, SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE)).orElse(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,6 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -32,16 +31,14 @@ import org.bukkit.inventory.meta.ItemMeta;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.network.Network;
|
import io.github.thebusybiscuit.slimefun4.api.network.Network;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.UniversalBlockMenu;
|
||||||
@ -368,7 +365,7 @@ abstract class AbstractItemNetwork extends Network {
|
|||||||
ItemMeta im = stack.getItemMeta();
|
ItemMeta im = stack.getItemMeta();
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(ChatColors.color("&7Stored Items: &f" + DoubleHandler.getFancyDouble(item.getInt())));
|
lore.add(ChatColors.color("&7Stored Items: &f" + NumberUtils.getCompactDouble(item.getInt())));
|
||||||
|
|
||||||
if (stack.getMaxStackSize() > 1) {
|
if (stack.getMaxStackSize() > 1) {
|
||||||
int amount = item.getInt() > stack.getMaxStackSize() ? stack.getMaxStackSize() : item.getInt();
|
int amount = item.getInt() > stack.getMaxStackSize() ? stack.getMaxStackSize() : item.getInt();
|
||||||
@ -426,12 +423,7 @@ abstract class AbstractItemNetwork extends Network {
|
|||||||
}
|
}
|
||||||
} else if (BlockStorage.hasInventory(target)) {
|
} else if (BlockStorage.hasInventory(target)) {
|
||||||
BlockMenu blockMenu = BlockStorage.getInventory(target);
|
BlockMenu blockMenu = BlockStorage.getInventory(target);
|
||||||
|
|
||||||
if (blockMenu.getPreset().getID().startsWith("BARREL_")) {
|
|
||||||
gatherItemsFromBarrel(l, blockMenu, items);
|
|
||||||
} else {
|
|
||||||
handleWithdraw(blockMenu, items, l);
|
handleWithdraw(blockMenu, items, l);
|
||||||
}
|
|
||||||
} else if (CargoUtils.hasInventory(target)) {
|
} else if (CargoUtils.hasInventory(target)) {
|
||||||
BlockState state = PaperLib.getBlockState(target, false).getState();
|
BlockState state = PaperLib.getBlockState(target, false).getState();
|
||||||
|
|
||||||
@ -445,41 +437,6 @@ abstract class AbstractItemNetwork extends Network {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
|
||||||
private void gatherItemsFromBarrel(Location l, BlockMenu blockMenu, List<ItemStackAndInteger> items) {
|
|
||||||
try {
|
|
||||||
Config cfg = BlockStorage.getLocationInfo(blockMenu.getLocation());
|
|
||||||
String data = cfg.getString("storedItems");
|
|
||||||
|
|
||||||
if (data == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int stored = Integer.parseInt(data);
|
|
||||||
|
|
||||||
for (int slot : blockMenu.getPreset().getSlotsAccessedByItemTransport((DirtyChestMenu) blockMenu, ItemTransportFlow.WITHDRAW, null)) {
|
|
||||||
ItemStack stack = blockMenu.getItemInSlot(slot);
|
|
||||||
|
|
||||||
if (stack != null && CargoUtils.matchesFilter(this, l.getBlock(), stack)) {
|
|
||||||
boolean add = true;
|
|
||||||
|
|
||||||
for (ItemStackAndInteger item : items) {
|
|
||||||
if (SlimefunUtils.isItemSimilar(stack, item.getItemStackWrapper(), true, false)) {
|
|
||||||
add = false;
|
|
||||||
item.add(stack.getAmount() + stored);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (add) {
|
|
||||||
items.add(new ItemStackAndInteger(stack, stack.getAmount() + stored));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (Exception x) {
|
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Exception occurred while trying to read data from a Barrel", x);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void handleWithdraw(DirtyChestMenu menu, List<ItemStackAndInteger> items, Location l) {
|
private void handleWithdraw(DirtyChestMenu menu, List<ItemStackAndInteger> items, Location l) {
|
||||||
for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
|
for (int slot : menu.getPreset().getSlotsAccessedByItemTransport(menu, ItemTransportFlow.WITHDRAW, null)) {
|
||||||
|
@ -20,7 +20,6 @@ import io.github.thebusybiscuit.slimefun4.api.network.NetworkComponent;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
|
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link CargoNet} is a type of {@link Network} which deals with {@link ItemStack} transportation.
|
* The {@link CargoNet} is a type of {@link Network} which deals with {@link ItemStack} transportation.
|
||||||
@ -250,7 +249,7 @@ public class CargoNet extends AbstractItemNetwork {
|
|||||||
String str = BlockStorage.getLocationInfo(node).getString("frequency");
|
String str = BlockStorage.getLocationInfo(node).getString("frequency");
|
||||||
return str == null ? 0 : Integer.parseInt(str);
|
return str == null ? 0 : Integer.parseInt(str);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while parsing a Cargo Node Frequency (" + node.getWorld().getName() + " - " + node.getBlockX() + "," + node.getBlockY() + "," + +node.getBlockZ() + ")");
|
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "An Error occurred while parsing a Cargo Node Frequency (" + node.getWorld().getName() + " - " + node.getBlockX() + "," + node.getBlockY() + "," + +node.getBlockZ() + ")");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,9 +22,20 @@ import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
|||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
final class CargoUtils {
|
final class CargoUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,6 +43,10 @@ final class CargoUtils {
|
|||||||
*/
|
*/
|
||||||
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.
|
||||||
|
* Therefore we just hide the public constructor.
|
||||||
|
*/
|
||||||
private CargoUtils() {}
|
private CargoUtils() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -51,10 +66,6 @@ final class CargoUtils {
|
|||||||
|
|
||||||
Material type = block.getType();
|
Material type = block.getType();
|
||||||
|
|
||||||
if (SlimefunTag.SHULKER_BOXES.isTagged(type)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case CHEST:
|
case CHEST:
|
||||||
case TRAPPED_CHEST:
|
case TRAPPED_CHEST:
|
||||||
@ -68,10 +79,11 @@ final class CargoUtils {
|
|||||||
case SMOKER:
|
case SMOKER:
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
return false;
|
return SlimefunTag.SHULKER_BOXES.isTagged(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item) {
|
static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item) {
|
||||||
if (inv instanceof FurnaceInventory) {
|
if (inv instanceof FurnaceInventory) {
|
||||||
if (item != null && item.getType().isFuel()) {
|
if (item != null && item.getType().isFuel()) {
|
||||||
@ -101,7 +113,8 @@ final class CargoUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int[] getOutputSlotRange(Inventory inv) {
|
@Nonnull
|
||||||
|
static int[] getOutputSlotRange(@Nonnull Inventory inv) {
|
||||||
if (inv instanceof FurnaceInventory) {
|
if (inv instanceof FurnaceInventory) {
|
||||||
// Slot 2-3
|
// Slot 2-3
|
||||||
return new int[] { 2, 3 };
|
return new int[] { 2, 3 };
|
||||||
@ -114,6 +127,7 @@ final class CargoUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static ItemStack withdraw(AbstractItemNetwork network, Map<Location, Inventory> inventories, Block node, Block target, ItemStack template) {
|
static ItemStack withdraw(AbstractItemNetwork network, Map<Location, Inventory> inventories, Block node, Block target, ItemStack template) {
|
||||||
DirtyChestMenu menu = getChestMenu(target);
|
DirtyChestMenu menu = getChestMenu(target);
|
||||||
|
|
||||||
@ -145,7 +159,7 @@ final class CargoUtils {
|
|||||||
if (SlimefunUtils.isItemSimilar(is, wrapper, true) && matchesFilter(network, node, is)) {
|
if (SlimefunUtils.isItemSimilar(is, wrapper, true) && matchesFilter(network, node, is)) {
|
||||||
if (is.getAmount() > template.getAmount()) {
|
if (is.getAmount() > template.getAmount()) {
|
||||||
is.setAmount(is.getAmount() - template.getAmount());
|
is.setAmount(is.getAmount() - template.getAmount());
|
||||||
menu.replaceExistingItem(slot, is.clone());
|
menu.replaceExistingItem(slot, is);
|
||||||
return template;
|
return template;
|
||||||
} else {
|
} else {
|
||||||
menu.replaceExistingItem(slot, null);
|
menu.replaceExistingItem(slot, null);
|
||||||
@ -157,6 +171,7 @@ final class CargoUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block node, ItemStack template, Inventory inv) {
|
static ItemStack withdrawFromVanillaInventory(AbstractItemNetwork network, Block node, ItemStack template, Inventory inv) {
|
||||||
ItemStack[] contents = inv.getContents();
|
ItemStack[] contents = inv.getContents();
|
||||||
int[] range = getOutputSlotRange(inv);
|
int[] range = getOutputSlotRange(inv);
|
||||||
@ -184,6 +199,7 @@ final class CargoUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map<Location, Inventory> inventories, Block node, Block target) {
|
static ItemStackAndInteger withdraw(AbstractItemNetwork network, Map<Location, Inventory> inventories, Block node, Block target) {
|
||||||
DirtyChestMenu menu = getChestMenu(target);
|
DirtyChestMenu menu = getChestMenu(target);
|
||||||
|
|
||||||
@ -215,6 +231,7 @@ final class CargoUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static ItemStackAndInteger withdrawFromVanillaInventory(AbstractItemNetwork network, Block node, Inventory inv) {
|
private static ItemStackAndInteger withdrawFromVanillaInventory(AbstractItemNetwork network, Block node, Inventory inv) {
|
||||||
ItemStack[] contents = inv.getContents();
|
ItemStack[] contents = inv.getContents();
|
||||||
int[] range = getOutputSlotRange(inv);
|
int[] range = getOutputSlotRange(inv);
|
||||||
@ -233,6 +250,7 @@ final class CargoUtils {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static ItemStack insert(AbstractItemNetwork network, Map<Location, Inventory> inventories, Block node, Block target, ItemStack stack) {
|
static ItemStack insert(AbstractItemNetwork network, Map<Location, Inventory> inventories, Block node, Block target, ItemStack stack) {
|
||||||
if (!matchesFilter(network, node, stack)) {
|
if (!matchesFilter(network, node, stack)) {
|
||||||
return stack;
|
return stack;
|
||||||
@ -273,7 +291,7 @@ final class CargoUtils {
|
|||||||
int maxStackSize = itemInSlot.getType().getMaxStackSize();
|
int maxStackSize = itemInSlot.getType().getMaxStackSize();
|
||||||
int currentAmount = itemInSlot.getAmount();
|
int currentAmount = itemInSlot.getAmount();
|
||||||
|
|
||||||
if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) && currentAmount < maxStackSize) {
|
if (currentAmount < maxStackSize && SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false)) {
|
||||||
int amount = currentAmount + stack.getAmount();
|
int amount = currentAmount + stack.getAmount();
|
||||||
|
|
||||||
itemInSlot.setAmount(Math.min(amount, maxStackSize));
|
itemInSlot.setAmount(Math.min(amount, maxStackSize));
|
||||||
@ -291,6 +309,7 @@ final class CargoUtils {
|
|||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) {
|
private static ItemStack insertIntoVanillaInventory(ItemStack stack, Inventory inv) {
|
||||||
ItemStack[] contents = inv.getContents();
|
ItemStack[] contents = inv.getContents();
|
||||||
int[] range = getInputSlotRange(inv, stack);
|
int[] range = getInputSlotRange(inv, stack);
|
||||||
@ -309,7 +328,7 @@ final class CargoUtils {
|
|||||||
} else {
|
} else {
|
||||||
int maxStackSize = itemInSlot.getType().getMaxStackSize();
|
int maxStackSize = itemInSlot.getType().getMaxStackSize();
|
||||||
|
|
||||||
if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) && itemInSlot.getAmount() < maxStackSize) {
|
if (itemInSlot.getAmount() < maxStackSize && SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false)) {
|
||||||
int amount = itemInSlot.getAmount() + stack.getAmount();
|
int amount = itemInSlot.getAmount() + stack.getAmount();
|
||||||
|
|
||||||
if (amount > maxStackSize) {
|
if (amount > maxStackSize) {
|
||||||
@ -327,13 +346,14 @@ final class CargoUtils {
|
|||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
static DirtyChestMenu getChestMenu(@Nonnull Block block) {
|
static DirtyChestMenu getChestMenu(@Nonnull Block block) {
|
||||||
if (BlockStorage.hasInventory(block)) {
|
if (BlockStorage.hasInventory(block)) {
|
||||||
return BlockStorage.getInventory(block);
|
return BlockStorage.getInventory(block);
|
||||||
}
|
} else {
|
||||||
|
|
||||||
return BlockStorage.getUniversalInventory(block);
|
return BlockStorage.getUniversalInventory(block);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static boolean matchesFilter(@Nonnull AbstractItemNetwork network, @Nonnull Block node, @Nullable ItemStack item) {
|
static boolean matchesFilter(@Nonnull AbstractItemNetwork network, @Nonnull Block node, @Nullable ItemStack item) {
|
||||||
if (item == null || item.getType() == Material.AIR) {
|
if (item == null || item.getType() == Material.AIR) {
|
||||||
@ -365,20 +385,12 @@ final class CargoUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isPotion(@Nullable ItemStack item) {
|
private static boolean isPotion(@Nullable ItemStack item) {
|
||||||
return item != null && (item.getType() == Material.POTION || item.getType() == Material.SPLASH_POTION || item.getType() == Material.LINGERING_POTION);
|
if (item != null) {
|
||||||
|
Material type = item.getType();
|
||||||
|
return type == Material.POTION || type == Material.SPLASH_POTION || type == Material.LINGERING_POTION;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the whitelist/blacklist slots in a Cargo Input Node. If you wish to access the items
|
|
||||||
* in the cargo (without hardcoding the slots in case of change) then you can use this method.
|
|
||||||
*
|
|
||||||
* @deprecated Renamed to {@link #getFilteringSlots()}
|
|
||||||
*
|
|
||||||
* @return The slot indexes for the whitelist/blacklist section.
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static int[] getWhitelistBlacklistSlots() {
|
|
||||||
return FILTER_SLOTS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -387,6 +399,7 @@ final class CargoUtils {
|
|||||||
*
|
*
|
||||||
* @return The slots where the {@link ItemFilter} section for a cargo node sits
|
* @return The slots where the {@link ItemFilter} section for a cargo node sits
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static int[] getFilteringSlots() {
|
public static int[] getFilteringSlots() {
|
||||||
return FILTER_SLOTS;
|
return FILTER_SLOTS;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import org.bukkit.entity.Player;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Service is responsible for automatically saving {@link Player} and {@link Block}
|
* This Service is responsible for automatically saving {@link Player} and {@link Block}
|
||||||
@ -66,7 +65,7 @@ public class AutoSavingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (players > 0) {
|
if (players > 0) {
|
||||||
Slimefun.getLogger().log(Level.INFO, "Auto-saved all player data for {0} player(s)!", players);
|
SlimefunPlugin.logger().log(Level.INFO, "Auto-saved all player data for {0} player(s)!", players);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,7 +88,7 @@ public class AutoSavingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!worlds.isEmpty()) {
|
if (!worlds.isEmpty()) {
|
||||||
Slimefun.getLogger().log(Level.INFO, "Auto-saving block data... (Next auto-save: {0}m)", interval);
|
SlimefunPlugin.logger().log(Level.INFO, "Auto-saving block data... (Next auto-save: {0}m)", interval);
|
||||||
|
|
||||||
for (BlockStorage storage : worlds) {
|
for (BlockStorage storage : worlds) {
|
||||||
storage.save();
|
storage.save();
|
||||||
|
@ -20,7 +20,6 @@ import javax.annotation.Nonnull;
|
|||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Service creates a Backup of your Slimefun world data on every server shutdown.
|
* This Service creates a Backup of your Slimefun world data on every server shutdown.
|
||||||
@ -43,7 +42,7 @@ public class BackupService implements Runnable {
|
|||||||
try {
|
try {
|
||||||
purgeBackups(backups);
|
purgeBackups(backups);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Could not delete an old backup", e);
|
SlimefunPlugin.logger().log(Level.WARNING, "Could not delete an old backup", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,12 +55,12 @@ public class BackupService implements Runnable {
|
|||||||
createBackup(output);
|
createBackup(output);
|
||||||
}
|
}
|
||||||
|
|
||||||
Slimefun.getLogger().log(Level.INFO, "Backed up Slimefun data to: {0}", file.getName());
|
SlimefunPlugin.logger().log(Level.INFO, "Backed up Slimefun data to: {0}", file.getName());
|
||||||
} else {
|
} else {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Could not create backup-file: {0}", file.getName());
|
SlimefunPlugin.logger().log(Level.WARNING, "Could not create backup-file: {0}", file.getName());
|
||||||
}
|
}
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while creating a backup for Slimefun " + SlimefunPlugin.getVersion());
|
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "An Error occurred while creating a backup for Slimefun " + SlimefunPlugin.getVersion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@ import org.bukkit.persistence.PersistentDataHolder;
|
|||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link BlockDataService} is similar to the {@link CustomItemDataService},
|
* The {@link BlockDataService} is similar to the {@link CustomItemDataService},
|
||||||
@ -78,12 +78,12 @@ public class BlockDataService implements Keyed {
|
|||||||
container.set(namespacedKey, PersistentDataType.STRING, value);
|
container.set(namespacedKey, PersistentDataType.STRING, value);
|
||||||
state.update();
|
state.update();
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "Please check if your Server Software is up to date!");
|
SlimefunPlugin.logger().log(Level.SEVERE, "Please check if your Server Software is up to date!");
|
||||||
|
|
||||||
String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName();
|
String serverSoftware = PaperLib.isSpigot() && !PaperLib.isPaper() ? "Spigot" : Bukkit.getName();
|
||||||
Slimefun.getLogger().log(Level.SEVERE, () -> serverSoftware + " | " + Bukkit.getVersion() + " | " + Bukkit.getBukkitVersion());
|
SlimefunPlugin.logger().log(Level.SEVERE, () -> serverSoftware + " | " + Bukkit.getVersion() + " | " + Bukkit.getBukkitVersion());
|
||||||
|
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Exception was thrown while trying to set Persistent Data for a Block", x);
|
SlimefunPlugin.logger().log(Level.SEVERE, "An Exception was thrown while trying to set Persistent Data for a Block", x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,9 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
*/
|
*/
|
||||||
public class CustomItemDataService implements Keyed {
|
public class CustomItemDataService implements Keyed {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the {@link NamespacedKey} used to store/read data.
|
||||||
|
*/
|
||||||
private final NamespacedKey namespacedKey;
|
private final NamespacedKey namespacedKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,11 +23,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization;
|
import io.github.thebusybiscuit.slimefun4.core.services.localization.SlimefunLocalization;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* As the name suggests, this Service is responsible for Localization.
|
* As the name suggests, this Service is responsible for Localization.
|
||||||
@ -78,7 +77,7 @@ public class LocalizationService extends SlimefunLocalization {
|
|||||||
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.getLogger().log(Level.INFO, "Available languages: {0}", String.join(", ", languages.keySet()));
|
SlimefunPlugin.logger().log(Level.INFO, "Available languages: {0}", String.join(", ", languages.keySet()));
|
||||||
save();
|
save();
|
||||||
} else {
|
} else {
|
||||||
translationsEnabled = false;
|
translationsEnabled = false;
|
||||||
@ -178,7 +177,7 @@ public class LocalizationService extends SlimefunLocalization {
|
|||||||
defaultLanguage.setCategoriesFile(streamConfigFile("categories_" + language + ".yml", null));
|
defaultLanguage.setCategoriesFile(streamConfigFile("categories_" + language + ".yml", null));
|
||||||
defaultLanguage.setRecipeTypesFile(streamConfigFile("recipes_" + language + ".yml", null));
|
defaultLanguage.setRecipeTypesFile(streamConfigFile("recipes_" + language + ".yml", null));
|
||||||
|
|
||||||
Slimefun.getLogger().log(Level.INFO, "Loaded language \"{0}\"", language);
|
SlimefunPlugin.logger().log(Level.INFO, "Loaded language \"{0}\"", language);
|
||||||
getConfig().setValue(LANGUAGE_PATH, language);
|
getConfig().setValue(LANGUAGE_PATH, language);
|
||||||
|
|
||||||
// Loading in the defaults from our resources folder
|
// Loading in the defaults from our resources folder
|
||||||
@ -188,7 +187,7 @@ public class LocalizationService extends SlimefunLocalization {
|
|||||||
FileConfiguration config = YamlConfiguration.loadConfiguration(reader);
|
FileConfiguration config = YamlConfiguration.loadConfiguration(reader);
|
||||||
getConfig().getConfiguration().setDefaults(config);
|
getConfig().getConfiguration().setDefaults(config);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, e, () -> "Failed to load language file: \"" + path + "\"");
|
SlimefunPlugin.logger().log(Level.SEVERE, e, () -> "Failed to load language file: \"" + path + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
save();
|
||||||
@ -245,13 +244,15 @@ public class LocalizationService extends SlimefunLocalization {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.min(DoubleHandler.fixDouble(100.0 * (matches / (double) defaultKeys.size())), 100.0);
|
return Math.min(NumberUtils.reparseDouble(100.0 * (matches / (double) defaultKeys.size())), 100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
private Set<String> getTotalKeys(@Nonnull Language lang) {
|
private Set<String> getTotalKeys(@Nonnull Language lang) {
|
||||||
return getKeys(lang.getFiles());
|
return getKeys(lang.getFiles());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
private Set<String> getKeys(FileConfiguration... files) {
|
private Set<String> getKeys(FileConfiguration... files) {
|
||||||
Set<String> keys = new HashSet<>();
|
Set<String> keys = new HashSet<>();
|
||||||
|
|
||||||
@ -278,7 +279,7 @@ public class LocalizationService extends SlimefunLocalization {
|
|||||||
|
|
||||||
return config;
|
return config;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, e, () -> "Failed to load language file into memory: \"" + path + "\"");
|
SlimefunPlugin.logger().log(Level.SEVERE, e, () -> "Failed to load language file into memory: \"" + path + "\"");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ import org.bukkit.plugin.Plugin;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
||||||
import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot;
|
import io.github.thebusybiscuit.cscorelib2.recipes.RecipeSnapshot;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Service is responsible for accessing a {@link RecipeSnapshot}.
|
* This Service is responsible for accessing a {@link RecipeSnapshot}.
|
||||||
* This snapshot contains a compiled list of all recipes that could be found on the
|
* This snapshot contains a compiled list of all recipes that could be found on the
|
||||||
* Server at the time the Service was loaded.
|
* Server at the time the Service was loaded.
|
||||||
*
|
*
|
||||||
* This Service is primarily used by the {@link ChestSlimefunGuide}.
|
* This Service is primarily used by the {@link SurvivalSlimefunGuide}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
|
@ -9,10 +9,10 @@ import java.util.logging.Level;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import kong.unirest.JsonNode;
|
import kong.unirest.JsonNode;
|
||||||
import kong.unirest.json.JSONArray;
|
import kong.unirest.json.JSONArray;
|
||||||
import kong.unirest.json.JSONObject;
|
import kong.unirest.json.JSONObject;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
class ContributionsConnector extends GitHubConnector {
|
class ContributionsConnector extends GitHubConnector {
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class ContributionsConnector extends GitHubConnector {
|
|||||||
if (response.isArray()) {
|
if (response.isArray()) {
|
||||||
computeContributors(response.getArray());
|
computeContributors(response.getArray());
|
||||||
} else {
|
} else {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response);
|
SlimefunPlugin.logger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import javax.annotation.Nullable;
|
|||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.data.ComputedOptional;
|
import io.github.thebusybiscuit.cscorelib2.data.TriStateOptional;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class Contributor {
|
|||||||
private final String profileLink;
|
private final String profileLink;
|
||||||
|
|
||||||
private final ConcurrentMap<String, Integer> contributions = new ConcurrentHashMap<>();
|
private final ConcurrentMap<String, Integer> contributions = new ConcurrentHashMap<>();
|
||||||
private final ComputedOptional<String> headTexture = ComputedOptional.createNew();
|
private final TriStateOptional<String> headTexture = TriStateOptional.createNew();
|
||||||
|
|
||||||
private Optional<UUID> uuid = Optional.empty();
|
private Optional<UUID> uuid = Optional.empty();
|
||||||
private boolean immutable = false;
|
private boolean immutable = false;
|
||||||
@ -181,10 +181,10 @@ public class Contributor {
|
|||||||
public String getTexture() {
|
public String getTexture() {
|
||||||
if (!headTexture.isComputed() || !headTexture.isPresent()) {
|
if (!headTexture.isComputed() || !headTexture.isPresent()) {
|
||||||
GitHubService github = SlimefunPlugin.getGitHubService();
|
GitHubService github = SlimefunPlugin.getGitHubService();
|
||||||
|
|
||||||
if (github != null) {
|
|
||||||
String cached = github.getCachedTexture(githubUsername);
|
String cached = github.getCachedTexture(githubUsername);
|
||||||
return cached != null ? cached : HeadTexture.UNKNOWN.getTexture();
|
|
||||||
|
if (cached != null) {
|
||||||
|
return cached;
|
||||||
} else {
|
} else {
|
||||||
return HeadTexture.UNKNOWN.getTexture();
|
return HeadTexture.UNKNOWN.getTexture();
|
||||||
}
|
}
|
||||||
|
@ -14,12 +14,12 @@ import java.util.logging.Level;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import kong.unirest.HttpResponse;
|
import kong.unirest.HttpResponse;
|
||||||
import kong.unirest.JsonNode;
|
import kong.unirest.JsonNode;
|
||||||
import kong.unirest.Unirest;
|
import kong.unirest.Unirest;
|
||||||
import kong.unirest.UnirestException;
|
import kong.unirest.UnirestException;
|
||||||
import kong.unirest.json.JSONException;
|
import kong.unirest.json.JSONException;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link GitHubConnector} is used to connect to the GitHub API service.
|
* The {@link GitHubConnector} is used to connect to the GitHub API service.
|
||||||
@ -100,7 +100,7 @@ abstract class GitHubConnector {
|
|||||||
file = new File("plugins/Slimefun/cache/github/" + getFileName() + ".json");
|
file = new File("plugins/Slimefun/cache/github/" + getFileName() + ".json");
|
||||||
|
|
||||||
if (github.isLoggingEnabled()) {
|
if (github.isLoggingEnabled()) {
|
||||||
Slimefun.getLogger().log(Level.INFO, "Retrieving {0}.json from GitHub...", getFileName());
|
SlimefunPlugin.logger().log(Level.INFO, "Retrieving {0}.json from GitHub...", getFileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -116,7 +116,7 @@ abstract class GitHubConnector {
|
|||||||
writeCacheFile(response.getBody());
|
writeCacheFile(response.getBody());
|
||||||
} else {
|
} else {
|
||||||
if (github.isLoggingEnabled()) {
|
if (github.isLoggingEnabled()) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { url, response.getStatus(), response.getBody() });
|
SlimefunPlugin.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
|
// It has the cached file, let's just read that then
|
||||||
@ -130,7 +130,7 @@ abstract class GitHubConnector {
|
|||||||
}
|
}
|
||||||
} catch (UnirestException e) {
|
} catch (UnirestException e) {
|
||||||
if (github.isLoggingEnabled()) {
|
if (github.isLoggingEnabled()) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time.", e);
|
SlimefunPlugin.logger().log(Level.WARNING, "Could not connect to GitHub in time.", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// It has the cached file, let's just read that then
|
// It has the cached file, let's just read that then
|
||||||
@ -153,7 +153,7 @@ abstract class GitHubConnector {
|
|||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) {
|
||||||
return new JsonNode(reader.readLine());
|
return new JsonNode(reader.readLine());
|
||||||
} catch (IOException | JSONException e) {
|
} catch (IOException | JSONException e) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] { file.getName(), e.getClass().getSimpleName(), e.getMessage() });
|
SlimefunPlugin.logger().log(Level.WARNING, "Failed to read Github cache file: {0} - {1}: {2}", new Object[] { file.getName(), e.getClass().getSimpleName(), e.getMessage() });
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ abstract class GitHubConnector {
|
|||||||
try (FileOutputStream output = new FileOutputStream(file)) {
|
try (FileOutputStream output = new FileOutputStream(file)) {
|
||||||
output.write(node.toString().getBytes(StandardCharsets.UTF_8));
|
output.write(node.toString().getBytes(StandardCharsets.UTF_8));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Failed to populate GitHub cache: {0} - {1}", new Object[] { e.getClass().getSimpleName(), e.getMessage() });
|
SlimefunPlugin.logger().log(Level.WARNING, "Failed to populate GitHub cache: {0} - {1}", new Object[] { e.getClass().getSimpleName(), e.getMessage() });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,10 +7,10 @@ import java.util.logging.Level;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import kong.unirest.JsonNode;
|
import kong.unirest.JsonNode;
|
||||||
import kong.unirest.json.JSONArray;
|
import kong.unirest.json.JSONArray;
|
||||||
import kong.unirest.json.JSONObject;
|
import kong.unirest.json.JSONObject;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
class GitHubIssuesConnector extends GitHubConnector {
|
class GitHubIssuesConnector extends GitHubConnector {
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class GitHubIssuesConnector extends GitHubConnector {
|
|||||||
|
|
||||||
callback.accept(issues, pullRequests);
|
callback.accept(issues, pullRequests);
|
||||||
} else {
|
} else {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response);
|
SlimefunPlugin.logger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,9 +14,8 @@ import javax.annotation.Nullable;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount;
|
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount;
|
||||||
import io.github.thebusybiscuit.cscorelib2.players.MinecraftAccount.TooManyRequestsException;
|
import io.github.thebusybiscuit.cscorelib2.players.TooManyRequestsException;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link GitHubTask} represents a {@link Runnable} that is run every X minutes.
|
* This {@link GitHubTask} represents a {@link Runnable} that is run every X minutes.
|
||||||
@ -101,8 +100,8 @@ class GitHubTask implements Runnable {
|
|||||||
contributor.setTexture(null);
|
contributor.setTexture(null);
|
||||||
} catch (IOException x) {
|
} catch (IOException x) {
|
||||||
// Too many requests
|
// Too many requests
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Attempted to connect to mojang.com, got this response: {0}: {1}", new Object[] { x.getClass().getSimpleName(), x.getMessage() });
|
SlimefunPlugin.logger().log(Level.WARNING, "Attempted to connect to mojang.com, got this response: {0}: {1}", new Object[] { x.getClass().getSimpleName(), x.getMessage() });
|
||||||
Slimefun.getLogger().log(Level.WARNING, "This usually means mojang.com is temporarily down or started to rate-limit this connection, this is not an error message!");
|
SlimefunPlugin.logger().log(Level.WARNING, "This usually means mojang.com is temporarily down or started to rate-limit this connection, this is not an error message!");
|
||||||
|
|
||||||
// Retry after 5 minutes if it was rate-limiting
|
// Retry after 5 minutes if it was rate-limiting
|
||||||
if (x.getMessage().contains("429")) {
|
if (x.getMessage().contains("429")) {
|
||||||
@ -111,7 +110,7 @@ class GitHubTask implements Runnable {
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
} catch (TooManyRequestsException x) {
|
} catch (TooManyRequestsException x) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Received a rate-limit from mojang.com, retrying in 4 minutes");
|
SlimefunPlugin.logger().log(Level.WARNING, "Received a rate-limit from mojang.com, retrying in 4 minutes");
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance(), this::grabTextures, 4 * 60 * 20L);
|
Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance(), this::grabTextures, 4 * 60 * 20L);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -36,6 +36,8 @@ public class Translators {
|
|||||||
addTranslator("ishi-sama", SupportedLanguage.FRENCH, true);
|
addTranslator("ishi-sama", SupportedLanguage.FRENCH, true);
|
||||||
addTranslator("amarcais53", SupportedLanguage.FRENCH, true);
|
addTranslator("amarcais53", SupportedLanguage.FRENCH, true);
|
||||||
addTranslator("NinoFutur", SupportedLanguage.FRENCH, true);
|
addTranslator("NinoFutur", SupportedLanguage.FRENCH, true);
|
||||||
|
addTranslator("TheRetix", SupportedLanguage.FRENCH, true);
|
||||||
|
addTranslator("Aeris1One", SupportedLanguage.FRENCH, true);
|
||||||
|
|
||||||
// Translators - Italian
|
// Translators - Italian
|
||||||
addTranslator("xXDOTTORXx", SupportedLanguage.ITALIAN, true);
|
addTranslator("xXDOTTORXx", SupportedLanguage.ITALIAN, true);
|
||||||
@ -50,6 +52,8 @@ public class Translators {
|
|||||||
|
|
||||||
// Translators - Hungarian
|
// Translators - Hungarian
|
||||||
addTranslator("andris155", SupportedLanguage.HUNGARIAN, true);
|
addTranslator("andris155", SupportedLanguage.HUNGARIAN, true);
|
||||||
|
addTranslator("KingDeadZ", SupportedLanguage.HUNGARIAN, true);
|
||||||
|
addTranslator("poma123", SupportedLanguage.HUNGARIAN, false);
|
||||||
|
|
||||||
// Translators - Vietnamese
|
// Translators - Vietnamese
|
||||||
addTranslator("HSGamer", SupportedLanguage.VIETNAMESE, false);
|
addTranslator("HSGamer", SupportedLanguage.VIETNAMESE, false);
|
||||||
@ -164,6 +168,7 @@ public class Translators {
|
|||||||
|
|
||||||
// Translators - Bulgarian
|
// Translators - Bulgarian
|
||||||
addTranslator("DNBGlol", SupportedLanguage.BULGARIAN, true);
|
addTranslator("DNBGlol", SupportedLanguage.BULGARIAN, true);
|
||||||
|
addTranslator("Pukejoy", SupportedLanguage.BULGARIAN, true);
|
||||||
|
|
||||||
// Translators - Tagalog
|
// Translators - Tagalog
|
||||||
addTranslator("sccooottttie", SupportedLanguage.TAGALOG, true);
|
addTranslator("sccooottttie", SupportedLanguage.TAGALOG, true);
|
||||||
@ -177,8 +182,10 @@ public class Translators {
|
|||||||
addTranslator("Sakanas", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
addTranslator("Sakanas", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
addTranslator("krazybeat", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
addTranslator("krazybeat", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
addTranslator("FaolanMalcadh", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
addTranslator("FaolanMalcadh", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
addTranslator("G4stavoM1ster", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
|
||||||
addTranslator("Gusstavo", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
addTranslator("Gusstavo", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
|
addTranslator("Day-OS", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
|
addTranslator("ooicram", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
|
addTranslator("Sxigames", SupportedLanguage.PORTUGUESE_BRAZIL, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.integrations.IntegrationsManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This Service holds all interactions and hooks with third-party {@link Plugin Plugins}
|
|
||||||
* that are not necessarily a dependency or a {@link SlimefunAddon}.
|
|
||||||
*
|
|
||||||
* Integration with these plugins happens inside Slimefun itself.
|
|
||||||
*
|
|
||||||
* @author TheBusyBiscuit
|
|
||||||
*
|
|
||||||
* @deprecated Renamed to {@link IntegrationsManager}
|
|
||||||
*
|
|
||||||
* @see SlimefunPlugin
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public class ThirdPartyPluginService extends IntegrationsManager {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This gets overridden if ExoticGarden is loaded
|
|
||||||
*/
|
|
||||||
private Function<Block, Optional<ItemStack>> exoticGardenIntegration = b -> Optional.empty();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This initializes the {@link ThirdPartyPluginService}
|
|
||||||
*
|
|
||||||
* @param plugin
|
|
||||||
* Our instance of {@link SlimefunPlugin}
|
|
||||||
*/
|
|
||||||
public ThirdPartyPluginService(@Nonnull SlimefunPlugin plugin) {
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void loadExoticGarden(Plugin plugin, Function<Block, Optional<ItemStack>> method) {
|
|
||||||
// TODO: Move this method to IntegrationsManager and think of a better way to handle this
|
|
||||||
if (plugin.getName().equals("ExoticGarden")) {
|
|
||||||
exoticGardenIntegration = method;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Optional<ItemStack> harvestExoticGardenPlant(Block block) {
|
|
||||||
return exoticGardenIntegration.apply(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
/**
|
|
||||||
* This package contains all hooks to external plugins
|
|
||||||
*/
|
|
||||||
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
|
|
@ -0,0 +1,41 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.core.services.profiler;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface is used to identify someone as a {@link PerformanceInspector}.
|
||||||
|
* A {@link PerformanceInspector} can query the {@link SlimefunProfiler} and get the
|
||||||
|
* results send to them as a {@link PerformanceSummary}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface PerformanceInspector {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns whether this {@link PerformanceInspector} is still valid.
|
||||||
|
* An inspector will become invalid if they leave the {@link Server}.
|
||||||
|
*
|
||||||
|
* @return Whether this inspector is still valid
|
||||||
|
*/
|
||||||
|
boolean isValid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This will send a text message to the {@link PerformanceInspector}.
|
||||||
|
*
|
||||||
|
* @param msg
|
||||||
|
* The message to send
|
||||||
|
*/
|
||||||
|
void sendMessage(@Nonnull String msg);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This determines whether the {@link PerformanceInspector} will get the full view
|
||||||
|
* or a trimmed version which only shows the most urgent samples.
|
||||||
|
*
|
||||||
|
* @return Whether to send the full {@link PerformanceSummary} or a trimmed version
|
||||||
|
*/
|
||||||
|
boolean isVerbose();
|
||||||
|
|
||||||
|
}
|
@ -11,10 +11,8 @@ import java.util.stream.Stream;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
@ -54,7 +52,7 @@ class PerformanceSummary {
|
|||||||
items = profiler.getByItem();
|
items = profiler.getByItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void send(@Nonnull CommandSender sender) {
|
public void send(@Nonnull PerformanceInspector sender) {
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(ChatColor.GREEN + "===== Slimefun Lag Profiler =====");
|
sender.sendMessage(ChatColor.GREEN + "===== Slimefun Lag Profiler =====");
|
||||||
sender.sendMessage(ChatColor.GOLD + "Total time: " + ChatColor.YELLOW + NumberUtils.getAsMillis(totalElapsedTime));
|
sender.sendMessage(ChatColor.GOLD + "Total time: " + ChatColor.YELLOW + NumberUtils.getAsMillis(totalElapsedTime));
|
||||||
@ -91,17 +89,17 @@ class PerformanceSummary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void summarizeTimings(int count, String name, CommandSender sender, Map<String, Long> map, Function<Map.Entry<String, Long>, String> formatter) {
|
private void summarizeTimings(int count, String name, PerformanceInspector inspector, Map<String, Long> map, Function<Map.Entry<String, Long>, String> formatter) {
|
||||||
Stream<Map.Entry<String, Long>> stream = map.entrySet().stream();
|
Stream<Map.Entry<String, Long>> stream = map.entrySet().stream();
|
||||||
List<Entry<String, Long>> results = stream.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).collect(Collectors.toList());
|
List<Entry<String, Long>> results = stream.sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())).collect(Collectors.toList());
|
||||||
String prefix = count + " " + name + (count != 1 ? 's' : "");
|
String prefix = count + " " + name + (count != 1 ? 's' : "");
|
||||||
|
|
||||||
if (sender instanceof Player) {
|
if (inspector instanceof PlayerPerformanceInspector) {
|
||||||
TextComponent component = summarizeAsTextComponent(count, prefix, results, formatter);
|
TextComponent component = summarizeAsTextComponent(count, prefix, results, formatter);
|
||||||
sender.spigot().sendMessage(component);
|
((PlayerPerformanceInspector) inspector).sendMessage(component);
|
||||||
} else {
|
} else {
|
||||||
String text = summarizeAsString(count, prefix, results, formatter);
|
String text = summarizeAsString(inspector, count, prefix, results, formatter);
|
||||||
sender.sendMessage(text);
|
inspector.sendMessage(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +141,7 @@ class PerformanceSummary {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private String summarizeAsString(int count, String prefix, List<Entry<String, Long>> results, Function<Entry<String, Long>, String> formatter) {
|
private String summarizeAsString(PerformanceInspector inspector, int count, String prefix, List<Entry<String, Long>> results, Function<Entry<String, Long>, String> formatter) {
|
||||||
int shownEntries = 0;
|
int shownEntries = 0;
|
||||||
int hiddenEntries = 0;
|
int hiddenEntries = 0;
|
||||||
|
|
||||||
@ -154,7 +152,7 @@ class PerformanceSummary {
|
|||||||
builder.append(ChatColor.YELLOW);
|
builder.append(ChatColor.YELLOW);
|
||||||
|
|
||||||
for (Map.Entry<String, Long> entry : results) {
|
for (Map.Entry<String, Long> entry : results) {
|
||||||
if (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("\n ");
|
||||||
builder.append(ChatColor.stripColor(formatter.apply(entry)));
|
builder.append(ChatColor.stripColor(formatter.apply(entry)));
|
||||||
shownEntries++;
|
shownEntries++;
|
||||||
|
@ -19,7 +19,6 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.scheduler.BukkitScheduler;
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
@ -27,7 +26,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link SlimefunProfiler} works closely to the {@link TickerTask} and is
|
* The {@link SlimefunProfiler} works closely to the {@link TickerTask} and is
|
||||||
@ -69,7 +67,7 @@ public class SlimefunProfiler {
|
|||||||
private long totalElapsedTime;
|
private long totalElapsedTime;
|
||||||
|
|
||||||
private final Map<ProfiledBlock, Long> timings = new ConcurrentHashMap<>();
|
private final Map<ProfiledBlock, Long> timings = new ConcurrentHashMap<>();
|
||||||
private final Queue<CommandSender> requests = new ConcurrentLinkedQueue<>();
|
private final Queue<PerformanceInspector> requests = new ConcurrentLinkedQueue<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method terminates the {@link SlimefunProfiler}.
|
* This method terminates the {@link SlimefunProfiler}.
|
||||||
@ -183,7 +181,7 @@ public class SlimefunProfiler {
|
|||||||
|
|
||||||
// If we waited for too long, then we should just abort
|
// If we waited for too long, then we should just abort
|
||||||
if (iterations <= 0) {
|
if (iterations <= 0) {
|
||||||
Iterator<CommandSender> iterator = requests.iterator();
|
Iterator<PerformanceInspector> iterator = requests.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
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 :/");
|
||||||
@ -193,7 +191,7 @@ public class SlimefunProfiler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "A Profiler Thread was interrupted", e);
|
SlimefunPlugin.logger().log(Level.SEVERE, "A Profiler Thread was interrupted", e);
|
||||||
Thread.currentThread().interrupt();
|
Thread.currentThread().interrupt();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -207,7 +205,7 @@ public class SlimefunProfiler {
|
|||||||
|
|
||||||
if (!requests.isEmpty()) {
|
if (!requests.isEmpty()) {
|
||||||
PerformanceSummary summary = new PerformanceSummary(this, totalElapsedTime, timings.size());
|
PerformanceSummary summary = new PerformanceSummary(this, totalElapsedTime, timings.size());
|
||||||
Iterator<CommandSender> iterator = requests.iterator();
|
Iterator<PerformanceInspector> iterator = requests.iterator();
|
||||||
|
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
summary.send(iterator.next());
|
summary.send(iterator.next());
|
||||||
@ -217,16 +215,16 @@ public class SlimefunProfiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method requests a summary for the given {@link CommandSender}.
|
* This method requests a summary for the given {@link PerformanceInspector}.
|
||||||
* The summary will be sent upon the next available moment in time.
|
* The summary will be sent upon the next available moment in time.
|
||||||
*
|
*
|
||||||
* @param sender
|
* @param inspector
|
||||||
* The {@link CommandSender} who shall receive this summary.
|
* The {@link PerformanceInspector} who shall receive this summary.
|
||||||
*/
|
*/
|
||||||
public void requestSummary(@Nonnull CommandSender sender) {
|
public void requestSummary(@Nonnull PerformanceInspector inspector) {
|
||||||
Validate.notNull(sender, "Cannot request a summary for null");
|
Validate.notNull(inspector, "Cannot request a summary for null");
|
||||||
|
|
||||||
requests.add(sender);
|
requests.add(inspector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -0,0 +1,62 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ConsolePerformanceInspector implements PerformanceInspector {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our reference to the actual underlying {@link CommandSender}.
|
||||||
|
*/
|
||||||
|
private final CommandSender console;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a summary will be verbose or trimmed of.
|
||||||
|
*/
|
||||||
|
private final boolean verbose;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This creates a new {@link ConsolePerformanceInspector} for the given {@link CommandSender}.
|
||||||
|
*
|
||||||
|
* @param console
|
||||||
|
* The {@link CommandSender}, preferabbly a {@link ConsoleCommandSender}
|
||||||
|
* @param verbose
|
||||||
|
* Whether the summary will be verbose or not
|
||||||
|
*/
|
||||||
|
public ConsolePerformanceInspector(@Nonnull CommandSender console, boolean verbose) {
|
||||||
|
Validate.notNull(console, "CommandSender cannot be null");
|
||||||
|
|
||||||
|
this.console = console;
|
||||||
|
this.verbose = verbose;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
// The console is always "online".
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVerbose() {
|
||||||
|
return verbose;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(@Nonnull String msg) {
|
||||||
|
console.sendMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
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.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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class PlayerPerformanceInspector implements PerformanceInspector {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Our reference to the {@link UUID} of the {@link Player}.
|
||||||
|
*/
|
||||||
|
private final UUID uuid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This creates a new {@link PlayerPerformanceInspector} for the given {@link Player}.
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* The {@link Player}
|
||||||
|
*/
|
||||||
|
public PlayerPerformanceInspector(@Nonnull Player player) {
|
||||||
|
Validate.notNull(player, "Player cannot be null");
|
||||||
|
|
||||||
|
this.uuid = player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private Player getPlayer() {
|
||||||
|
return Bukkit.getPlayer(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid() {
|
||||||
|
Player player = getPlayer();
|
||||||
|
return player != null && player.isOnline();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isVerbose() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(@Nonnull String msg) {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
player.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendMessage(@Nonnull TextComponent component) {
|
||||||
|
Player player = getPlayer();
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
player.spigot().sendMessage(component);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* 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;
|
@ -8,6 +8,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -20,6 +21,7 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.inventory.Recipe;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
@ -27,9 +29,7 @@ import org.bukkit.plugin.java.JavaPluginLoader;
|
|||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectionManager;
|
||||||
import io.github.thebusybiscuit.cscorelib2.reflection.ReflectionUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException;
|
import io.github.thebusybiscuit.slimefun4.api.exceptions.TagMisconfigurationException;
|
||||||
@ -50,7 +50,6 @@ import io.github.thebusybiscuit.slimefun4.core.services.PerWorldSettingsService;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService;
|
import io.github.thebusybiscuit.slimefun4.core.services.PermissionsService;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
|
import io.github.thebusybiscuit.slimefun4.core.services.UpdaterService;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
|
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.plugins.ThirdPartyPluginService;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler;
|
import io.github.thebusybiscuit.slimefun4.core.services.profiler.SlimefunProfiler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
||||||
@ -76,6 +75,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurna
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GadgetsListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.GrapplingHookListener;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.HopperListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemDropListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemDropListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.ItemPickupListener;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
|
import io.github.thebusybiscuit.slimefun4.implementation.listeners.MultiBlockListener;
|
||||||
@ -113,6 +113,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.SlimefunStartupTask;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
import io.github.thebusybiscuit.slimefun4.implementation.tasks.TickerTask;
|
||||||
import io.github.thebusybiscuit.slimefun4.integrations.IntegrationsManager;
|
import io.github.thebusybiscuit.slimefun4.integrations.IntegrationsManager;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
@ -148,14 +149,14 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
private final BackupService backupService = new BackupService();
|
private final BackupService backupService = new BackupService();
|
||||||
private final PermissionsService permissionsService = new PermissionsService(this);
|
private final PermissionsService permissionsService = new PermissionsService(this);
|
||||||
private final PerWorldSettingsService worldSettingsService = new PerWorldSettingsService(this);
|
private final PerWorldSettingsService worldSettingsService = new PerWorldSettingsService(this);
|
||||||
private final ThirdPartyPluginService thirdPartySupportService = new ThirdPartyPluginService(this);
|
|
||||||
private final MinecraftRecipeService recipeService = new MinecraftRecipeService(this);
|
private final MinecraftRecipeService recipeService = new MinecraftRecipeService(this);
|
||||||
private final SlimefunProfiler profiler = new SlimefunProfiler();
|
|
||||||
private LocalizationService local;
|
|
||||||
|
|
||||||
|
private final IntegrationsManager integrations = new IntegrationsManager(this);
|
||||||
|
private final SlimefunProfiler profiler = new SlimefunProfiler();
|
||||||
|
|
||||||
|
private LocalizationService local;
|
||||||
private GPSNetwork gpsNetwork;
|
private GPSNetwork gpsNetwork;
|
||||||
private NetworkManager networkManager;
|
private NetworkManager networkManager;
|
||||||
private ProtectionManager protections;
|
|
||||||
|
|
||||||
// Important config files for Slimefun
|
// Important config files for Slimefun
|
||||||
private final Config config = new Config(this);
|
private final Config config = new Config(this);
|
||||||
@ -199,23 +200,63 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
instance = this;
|
|
||||||
|
|
||||||
if (minecraftVersion == MinecraftVersion.UNIT_TEST) {
|
if (minecraftVersion == MinecraftVersion.UNIT_TEST) {
|
||||||
|
// We handle Unit Tests seperately.
|
||||||
|
setInstance(this);
|
||||||
onUnitTestStart();
|
onUnitTestStart();
|
||||||
|
} else if (isVersionUnsupported()) {
|
||||||
|
// We wanna ensure that the Server uses a compatible version of Minecraft.
|
||||||
|
setInstance(this);
|
||||||
|
getLogger().log(Level.WARNING, "Slimefun was not installed properly! Disabling...");
|
||||||
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
} else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
} else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
|
||||||
|
// The Environment and dependencies have been validated.
|
||||||
|
setInstance(this);
|
||||||
getLogger().log(Level.INFO, "CS-CoreLib was detected!");
|
getLogger().log(Level.INFO, "CS-CoreLib was detected!");
|
||||||
|
onPluginStart();
|
||||||
|
} else {
|
||||||
|
// Terminate our Plugin instance
|
||||||
|
setInstance(null);
|
||||||
|
|
||||||
|
// CS-CoreLib has not been installed!
|
||||||
|
getLogger().log(Level.INFO, "#################### - INFO - ####################");
|
||||||
|
getLogger().log(Level.INFO, " ");
|
||||||
|
getLogger().log(Level.INFO, "Slimefun could not be loaded (yet).");
|
||||||
|
getLogger().log(Level.INFO, "It appears that you have not installed CS-CoreLib.");
|
||||||
|
getLogger().log(Level.INFO, "Please download and install CS-CoreLib manually:");
|
||||||
|
getLogger().log(Level.INFO, "https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
|
||||||
|
|
||||||
|
// Send a message upon doing /slimefun
|
||||||
|
getCommand("slimefun").setExecutor((sender, cmd, label, args) -> {
|
||||||
|
sender.sendMessage("You have forgotten to install CS-CoreLib! Slimefun is disabled.");
|
||||||
|
sender.sendMessage("https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is our start method for a Unit Test environment.
|
||||||
|
*/
|
||||||
|
private void onUnitTestStart() {
|
||||||
|
local = new LocalizationService(this, "", null);
|
||||||
|
gpsNetwork = new GPSNetwork();
|
||||||
|
networkManager = new NetworkManager(200);
|
||||||
|
command.register();
|
||||||
|
registry.load(this, config);
|
||||||
|
loadTags();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is our start method for a correct Slimefun installation.
|
||||||
|
*/
|
||||||
|
private void onPluginStart() {
|
||||||
long timestamp = System.nanoTime();
|
long timestamp = System.nanoTime();
|
||||||
PaperLib.suggestPaper(this);
|
|
||||||
|
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
getLogger().log(Level.INFO, "Paper was detected! Performance optimizations have been applied.");
|
getLogger().log(Level.INFO, "Paper was detected! Performance optimizations have been applied.");
|
||||||
}
|
} else {
|
||||||
|
PaperLib.suggestPaper(this);
|
||||||
// We wanna ensure that the Server uses a compatible version of Minecraft
|
|
||||||
if (isVersionUnsupported()) {
|
|
||||||
getServer().getPluginManager().disablePlugin(this);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disabling backwards-compatibility for fresh Slimefun installs
|
// Disabling backwards-compatibility for fresh Slimefun installs
|
||||||
@ -229,7 +270,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
// Creating all necessary Folders
|
// Creating all necessary Folders
|
||||||
getLogger().log(Level.INFO, "Creating directories...");
|
getLogger().log(Level.INFO, "Creating directories...");
|
||||||
createDirectories();
|
createDirectories();
|
||||||
registry.load(config);
|
registry.load(this, config);
|
||||||
|
|
||||||
// Set up localization
|
// Set up localization
|
||||||
getLogger().log(Level.INFO, "Loading language files...");
|
getLogger().log(Level.INFO, "Loading language files...");
|
||||||
@ -279,7 +320,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
|
|
||||||
// Initiating various Stuff and all items with a slight delay (0ms after the Server finished loading)
|
// Initiating various Stuff and all items with a slight delay (0ms after the Server finished loading)
|
||||||
runSync(new SlimefunStartupTask(this, () -> {
|
runSync(new SlimefunStartupTask(this, () -> {
|
||||||
protections = new ProtectionManager(getServer());
|
|
||||||
textureService.register(registry.getAllSlimefunItems(), true);
|
textureService.register(registry.getAllSlimefunItems(), true);
|
||||||
permissionsService.register(registry.getAllSlimefunItems(), true);
|
permissionsService.register(registry.getAllSlimefunItems(), true);
|
||||||
|
|
||||||
@ -292,8 +332,12 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
|
|
||||||
}), 0);
|
}), 0);
|
||||||
|
|
||||||
// Setting up the command /sf and all subcommands
|
// Setting up our commands
|
||||||
|
try {
|
||||||
command.register();
|
command.register();
|
||||||
|
} catch (Exception | LinkageError x) {
|
||||||
|
getLogger().log(Level.SEVERE, "An Exception occurred while registering the /slimefun command", x);
|
||||||
|
}
|
||||||
|
|
||||||
// Armor Update Task
|
// Armor Update Task
|
||||||
if (config.getBoolean("options.enable-armor-effects")) {
|
if (config.getBoolean("options.enable-armor-effects")) {
|
||||||
@ -301,44 +345,27 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorTask(radioactiveFire), 0L, config.getInt("options.armor-update-interval") * 20L);
|
getServer().getScheduler().runTaskTimerAsynchronously(this, new ArmorTask(radioactiveFire), 0L, config.getInt("options.armor-update-interval") * 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Starting our tasks
|
||||||
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
|
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
|
||||||
ticker.start(this);
|
ticker.start(this);
|
||||||
|
|
||||||
|
// Loading integrations
|
||||||
getLogger().log(Level.INFO, "Loading Third-Party plugin integrations...");
|
getLogger().log(Level.INFO, "Loading Third-Party plugin integrations...");
|
||||||
thirdPartySupportService.start();
|
integrations.start();
|
||||||
|
|
||||||
gitHubService.start(this);
|
gitHubService.start(this);
|
||||||
|
|
||||||
// Hooray!
|
// Hooray!
|
||||||
getLogger().log(Level.INFO, "Slimefun has finished loading in {0}", getStartupTime(timestamp));
|
getLogger().log(Level.INFO, "Slimefun has finished loading in {0}", getStartupTime(timestamp));
|
||||||
} else {
|
|
||||||
instance = null;
|
|
||||||
|
|
||||||
getLogger().log(Level.INFO, "#################### - INFO - ####################");
|
|
||||||
getLogger().log(Level.INFO, " ");
|
|
||||||
getLogger().log(Level.INFO, "Slimefun could not be loaded (yet).");
|
|
||||||
getLogger().log(Level.INFO, "It appears that you have not installed CS-CoreLib.");
|
|
||||||
getLogger().log(Level.INFO, "Please download and install CS-CoreLib manually:");
|
|
||||||
getLogger().log(Level.INFO, "https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
|
|
||||||
|
|
||||||
getCommand("slimefun").setExecutor((sender, cmd, label, args) -> {
|
|
||||||
sender.sendMessage("You have forgotten to install CS-CoreLib! Slimefun is disabled.");
|
|
||||||
sender.sendMessage("https://thebusybiscuit.github.io/builds/TheBusyBiscuit/CS-CoreLib/master/");
|
|
||||||
return true;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Override
|
||||||
* This is our start method for a Unit Test environment.
|
public JavaPlugin getJavaPlugin() {
|
||||||
*/
|
return this;
|
||||||
private void onUnitTestStart() {
|
}
|
||||||
local = new LocalizationService(this, "", null);
|
|
||||||
gpsNetwork = new GPSNetwork();
|
@Override
|
||||||
networkManager = new NetworkManager(200);
|
public String getBugTrackerURL() {
|
||||||
command.register();
|
return "https://github.com/Slimefun/Slimefun4/issues";
|
||||||
registry.load(config);
|
|
||||||
loadTags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -378,6 +405,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save all "universal" inventories (ender chests for example)
|
||||||
for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
|
for (UniversalBlockMenu menu : registry.getUniversalInventories().values()) {
|
||||||
menu.save();
|
menu.save();
|
||||||
}
|
}
|
||||||
@ -388,20 +416,11 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
// Close and unload any resources from our Metrics Service
|
// Close and unload any resources from our Metrics Service
|
||||||
metricsService.cleanUp();
|
metricsService.cleanUp();
|
||||||
|
|
||||||
/**
|
// Terminate our Plugin instance
|
||||||
* Prevent Memory Leaks for reloads...
|
setInstance(null);
|
||||||
* These static Maps should really be removed at some point...
|
|
||||||
*/
|
|
||||||
AContainer.processing = null;
|
|
||||||
AContainer.progress = null;
|
|
||||||
|
|
||||||
AGenerator.processing = null;
|
// Clean up any static fields
|
||||||
AGenerator.progress = null;
|
cleanUp();
|
||||||
|
|
||||||
Reactor.processing = null;
|
|
||||||
Reactor.progress = null;
|
|
||||||
|
|
||||||
instance = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Close all inventories on the server to prevent item dupes
|
* Close all inventories on the server to prevent item dupes
|
||||||
@ -412,17 +431,55 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is a private internal method to set the de-facto instance of {@link SlimefunPlugin}.
|
||||||
|
* Having this as a seperate method ensures the seperation between static and non-static fields.
|
||||||
|
* It also makes sonarcloud happy :)
|
||||||
|
* Only ever use it during {@link #onEnable()} or {@link #onDisable()}.
|
||||||
|
*
|
||||||
|
* @param pluginInstance
|
||||||
|
* Our instance of {@link SlimefunPlugin} or null
|
||||||
|
*/
|
||||||
|
private static void setInstance(@Nullable SlimefunPlugin pluginInstance) {
|
||||||
|
instance = pluginInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the time it took to load Slimefun (given a starting point).
|
||||||
|
*
|
||||||
|
* @param timestamp
|
||||||
|
* The time at which we started to load Slimefun.
|
||||||
|
*
|
||||||
|
* @return The total time it took to load Slimefun (in ms or s)
|
||||||
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private String getStartupTime(long timestamp) {
|
private String getStartupTime(long timestamp) {
|
||||||
long ms = (System.nanoTime() - timestamp) / 1000000;
|
long ms = (System.nanoTime() - timestamp) / 1000000;
|
||||||
|
|
||||||
if (ms > 1000) {
|
if (ms > 1000) {
|
||||||
return DoubleHandler.fixDouble(ms / 1000.0) + "s";
|
return NumberUtils.roundDecimalNumber(ms / 1000.0) + "s";
|
||||||
} else {
|
} else {
|
||||||
return DoubleHandler.fixDouble(ms) + "ms";
|
return NumberUtils.roundDecimalNumber(ms) + "ms";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cleaning up our static fields prevents memory leaks from a reload.
|
||||||
|
*
|
||||||
|
* @deprecated These static Maps should really be removed at some point...
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
private static void cleanUp() {
|
||||||
|
AContainer.processing = null;
|
||||||
|
AContainer.progress = null;
|
||||||
|
|
||||||
|
AGenerator.processing = null;
|
||||||
|
AGenerator.progress = null;
|
||||||
|
|
||||||
|
Reactor.processing = null;
|
||||||
|
Reactor.progress = null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method checks for the {@link MinecraftVersion} of the {@link Server}.
|
* This method checks for the {@link MinecraftVersion} of the {@link Server}.
|
||||||
* If the version is unsupported, a warning will be printed to the console.
|
* If the version is unsupported, a warning will be printed to the console.
|
||||||
@ -430,12 +487,29 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
* @return Whether the {@link MinecraftVersion} is unsupported
|
* @return Whether the {@link MinecraftVersion} is unsupported
|
||||||
*/
|
*/
|
||||||
private boolean isVersionUnsupported() {
|
private boolean isVersionUnsupported() {
|
||||||
String currentVersion = ReflectionUtils.getVersion();
|
try {
|
||||||
|
// First check if they still use the unsupported CraftBukkit software.
|
||||||
|
if (!PaperLib.isSpigot() && Bukkit.getName().equals("CraftBukkit")) {
|
||||||
|
getLogger().log(Level.SEVERE, "###############################################");
|
||||||
|
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
|
||||||
|
getLogger().log(Level.SEVERE, "### CraftBukkit is no longer supported!");
|
||||||
|
getLogger().log(Level.SEVERE, "###");
|
||||||
|
getLogger().log(Level.SEVERE, "### Slimefun requires you to use Spigot, Paper or");
|
||||||
|
getLogger().log(Level.SEVERE, "### any supported fork of Spigot or Paper.");
|
||||||
|
getLogger().log(Level.SEVERE, "### (We recommend Paper)");
|
||||||
|
getLogger().log(Level.SEVERE, "###############################################");
|
||||||
|
|
||||||
if (currentVersion.startsWith("v")) {
|
return true;
|
||||||
for (MinecraftVersion version : MinecraftVersion.valuesCache) {
|
}
|
||||||
if (version.matches(currentVersion)) {
|
|
||||||
minecraftVersion = version;
|
// Now check the actual Version of Minecraft
|
||||||
|
int version = PaperLib.getMinecraftVersion();
|
||||||
|
|
||||||
|
if (version > 0) {
|
||||||
|
// Check all supported versions of Minecraft
|
||||||
|
for (MinecraftVersion supportedVersion : MinecraftVersion.valuesCache) {
|
||||||
|
if (supportedVersion.isMinecraftVersion(version)) {
|
||||||
|
minecraftVersion = supportedVersion;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -445,17 +519,42 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
|
getLogger().log(Level.SEVERE, "### Slimefun was not installed correctly!");
|
||||||
getLogger().log(Level.SEVERE, "### You are using the wrong version of Minecraft!");
|
getLogger().log(Level.SEVERE, "### You are using the wrong version of Minecraft!");
|
||||||
getLogger().log(Level.SEVERE, "###");
|
getLogger().log(Level.SEVERE, "###");
|
||||||
getLogger().log(Level.SEVERE, "### You are using Minecraft {0}", currentVersion);
|
getLogger().log(Level.SEVERE, "### You are using Minecraft 1.{0}.x", version);
|
||||||
getLogger().log(Level.SEVERE, "### but Slimefun {0} requires you to be using", getDescription().getVersion());
|
getLogger().log(Level.SEVERE, "### but Slimefun {0} requires you to be using", getDescription().getVersion());
|
||||||
getLogger().log(Level.SEVERE, "### Minecraft {0}", String.join(" / ", getSupportedVersions()));
|
getLogger().log(Level.SEVERE, "### Minecraft {0}", String.join(" / ", getSupportedVersions()));
|
||||||
getLogger().log(Level.SEVERE, "#############################################");
|
getLogger().log(Level.SEVERE, "#############################################");
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
|
getLogger().log(Level.WARNING, "We could not determine the version of Minecraft you were using? ({0})", Bukkit.getVersion());
|
||||||
|
|
||||||
getLogger().log(Level.WARNING, "We could not determine the version of Minecraft you were using ({0})", currentVersion);
|
/*
|
||||||
|
* If we are unsure about it, we will assume "supported".
|
||||||
|
* They could be using a non-Bukkit based Software which still
|
||||||
|
* might support Bukkit-based plugins.
|
||||||
|
* Use at your own risk in this case.
|
||||||
|
*/
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
} catch (Exception | LinkageError x) {
|
||||||
|
getLogger().log(Level.SEVERE, x, () -> "Error: Could not determine Environment or version of Minecraft for Slimefun v" + getDescription().getVersion());
|
||||||
|
|
||||||
|
// We assume "unsupported" if something went wrong.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This private method gives us a {@link Collection} of every {@link MinecraftVersion}
|
||||||
|
* that Slimefun is compatible with (as a {@link String} representation).
|
||||||
|
* <p>
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* { 1.14.x, 1.15.x, 1.16.x }
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* @return A {@link Collection} of all compatible minecraft versions as strings
|
||||||
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private Collection<String> getSupportedVersions() {
|
private Collection<String> getSupportedVersions() {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
@ -469,6 +568,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method creates all necessary directories (and sub directories) for Slimefun.
|
||||||
|
*/
|
||||||
private void createDirectories() {
|
private void createDirectories() {
|
||||||
String[] storageFolders = { "Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups" };
|
String[] storageFolders = { "Players", "blocks", "stored-blocks", "stored-inventories", "stored-chunks", "universal-inventories", "waypoints", "block-backups" };
|
||||||
String[] pluginFolders = { "scripts", "error-reports", "cache/github", "world-settings" };
|
String[] pluginFolders = { "scripts", "error-reports", "cache/github", "world-settings" };
|
||||||
@ -524,6 +626,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
new CartographyTableListener(this);
|
new CartographyTableListener(this);
|
||||||
new ButcherAndroidListener(this);
|
new ButcherAndroidListener(this);
|
||||||
new NetworkListener(this, networkManager);
|
new NetworkListener(this, networkManager);
|
||||||
|
new HopperListener(this);
|
||||||
|
|
||||||
// Bees were added in 1.15
|
// Bees were added in 1.15
|
||||||
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
|
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
|
||||||
@ -564,6 +667,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
new PlayerProfileListener(this);
|
new PlayerProfileListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This (re)loads every {@link SlimefunTag}.
|
||||||
|
*/
|
||||||
private void loadTags() {
|
private void loadTags() {
|
||||||
for (SlimefunTag tag : SlimefunTag.valuesCache) {
|
for (SlimefunTag tag : SlimefunTag.valuesCache) {
|
||||||
try {
|
try {
|
||||||
@ -577,6 +683,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This loads all of our items.
|
||||||
|
*/
|
||||||
private void loadItems() {
|
private void loadItems() {
|
||||||
try {
|
try {
|
||||||
SlimefunItemSetup.setup(this);
|
SlimefunItemSetup.setup(this);
|
||||||
@ -585,6 +694,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This loads our researches.
|
||||||
|
*/
|
||||||
private void loadResearches() {
|
private void loadResearches() {
|
||||||
try {
|
try {
|
||||||
ResearchSetup.setupResearches();
|
ResearchSetup.setupResearches();
|
||||||
@ -593,6 +705,19 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This private static method allows us to throw a proper {@link Exception}
|
||||||
|
* whenever someone tries to access a static method while the instance is null.
|
||||||
|
* This happens when the method is invoked before {@link #onEnable()} or after {@link #onDisable()}.
|
||||||
|
* <p>
|
||||||
|
* Use it whenever a null check is needed to avoid a non-descriptive {@link NullPointerException}.
|
||||||
|
*/
|
||||||
|
private static void validateInstance() {
|
||||||
|
if (instance == null) {
|
||||||
|
throw new IllegalStateException("Cannot invoke static method, Slimefun instance is null.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the global instance of {@link SlimefunPlugin}.
|
* This returns the global instance of {@link SlimefunPlugin}.
|
||||||
* This may return null if the {@link Plugin} was disabled.
|
* This may return null if the {@link Plugin} was disabled.
|
||||||
@ -604,24 +729,17 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Config getCfg() {
|
/**
|
||||||
return instance.config;
|
* This returns the {@link Logger} instance that Slimefun uses.
|
||||||
}
|
* <p>
|
||||||
|
* <strong>Any {@link SlimefunAddon} should use their own {@link Logger} instance!</strong>
|
||||||
public static Config getResearchCfg() {
|
*
|
||||||
return instance.researches;
|
* @return Our {@link Logger} instance
|
||||||
}
|
*/
|
||||||
|
@Nonnull
|
||||||
public static Config getItemCfg() {
|
public static Logger logger() {
|
||||||
return instance.items;
|
validateInstance();
|
||||||
}
|
return instance.getLogger();
|
||||||
|
|
||||||
public static GPSNetwork getGPSNetwork() {
|
|
||||||
return instance.gpsNetwork;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TickerTask getTickerTask() {
|
|
||||||
return instance.ticker;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -629,59 +747,96 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*
|
*
|
||||||
* @return The currently installed version of Slimefun
|
* @return The currently installed version of Slimefun
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static String getVersion() {
|
public static String getVersion() {
|
||||||
|
validateInstance();
|
||||||
return instance.getDescription().getVersion();
|
return instance.getDescription().getVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Config getCfg() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Config getResearchCfg() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.researches;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static Config getItemCfg() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.items;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static GPSNetwork getGPSNetwork() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.gpsNetwork;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static TickerTask getTickerTask() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.ticker;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns the {@link LocalizationService} of Slimefun.
|
* This returns the {@link LocalizationService} of Slimefun.
|
||||||
*
|
*
|
||||||
* @return The {@link LocalizationService} of Slimefun
|
* @return The {@link LocalizationService} of Slimefun
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static LocalizationService getLocalization() {
|
public static LocalizationService getLocalization() {
|
||||||
|
validateInstance();
|
||||||
return instance.local;
|
return instance.local;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProtectionManager getProtectionManager() {
|
/**
|
||||||
return instance.protections;
|
* This method returns out {@link MinecraftRecipeService} for Slimefun.
|
||||||
}
|
* This service is responsible for finding/identifying {@link Recipe Recipes}
|
||||||
|
* from vanilla Minecraft.
|
||||||
|
*
|
||||||
|
* @return Slimefun's {@link MinecraftRecipeService} instance
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
public static MinecraftRecipeService getMinecraftRecipeService() {
|
public static MinecraftRecipeService getMinecraftRecipeService() {
|
||||||
|
validateInstance();
|
||||||
return instance.recipeService;
|
return instance.recipeService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static CustomItemDataService getItemDataService() {
|
public static CustomItemDataService getItemDataService() {
|
||||||
|
validateInstance();
|
||||||
return instance.itemDataService;
|
return instance.itemDataService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static CustomTextureService getItemTextureService() {
|
public static CustomTextureService getItemTextureService() {
|
||||||
|
validateInstance();
|
||||||
return instance.textureService;
|
return instance.textureService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static PermissionsService getPermissionsService() {
|
public static PermissionsService getPermissionsService() {
|
||||||
|
validateInstance();
|
||||||
return instance.permissionsService;
|
return instance.permissionsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static BlockDataService getBlockDataService() {
|
public static BlockDataService getBlockDataService() {
|
||||||
|
validateInstance();
|
||||||
return instance.blockDataService;
|
return instance.blockDataService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static PerWorldSettingsService getWorldSettingsService() {
|
public static PerWorldSettingsService getWorldSettingsService() {
|
||||||
|
validateInstance();
|
||||||
return instance.worldSettingsService;
|
return instance.worldSettingsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method has been renamed.
|
|
||||||
*
|
|
||||||
* @deprecated Please use {@link #getIntegrations()} instead.
|
|
||||||
*
|
|
||||||
* @return the {@link ThirdPartyPluginService}
|
|
||||||
*/
|
|
||||||
@Deprecated
|
|
||||||
public static ThirdPartyPluginService getThirdPartySupportService() {
|
|
||||||
return instance.thirdPartySupportService;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This returns our instance of {@link IntegrationsManager}.
|
* This returns our instance of {@link IntegrationsManager}.
|
||||||
* This is responsible for managing any integrations with third party {@link Plugin plugins}.
|
* This is responsible for managing any integrations with third party {@link Plugin plugins}.
|
||||||
@ -690,7 +845,19 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static IntegrationsManager getIntegrations() {
|
public static IntegrationsManager getIntegrations() {
|
||||||
return instance.thirdPartySupportService;
|
validateInstance();
|
||||||
|
return instance.integrations;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns out instance of the {@link ProtectionManager}.
|
||||||
|
* This bridge is used to hook into any third-party protection {@link Plugin}.
|
||||||
|
*
|
||||||
|
* @return Our instanceof of the {@link ProtectionManager}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static ProtectionManager getProtectionManager() {
|
||||||
|
return getIntegrations().getProtectionManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -699,7 +866,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*
|
*
|
||||||
* @return The {@link UpdaterService} for Slimefun
|
* @return The {@link UpdaterService} for Slimefun
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static UpdaterService getUpdater() {
|
public static UpdaterService getUpdater() {
|
||||||
|
validateInstance();
|
||||||
return instance.updaterService;
|
return instance.updaterService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -709,7 +878,9 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*
|
*
|
||||||
* @return The {@link MetricsService} for Slimefun
|
* @return The {@link MetricsService} for Slimefun
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static MetricsService getMetricsService() {
|
public static MetricsService getMetricsService() {
|
||||||
|
validateInstance();
|
||||||
return instance.metricsService;
|
return instance.metricsService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -719,30 +890,105 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*
|
*
|
||||||
* @return The {@link GitHubService} for Slimefun
|
* @return The {@link GitHubService} for Slimefun
|
||||||
*/
|
*/
|
||||||
|
@Nonnull
|
||||||
public static GitHubService getGitHubService() {
|
public static GitHubService getGitHubService() {
|
||||||
|
validateInstance();
|
||||||
return instance.gitHubService;
|
return instance.gitHubService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SlimefunRegistry getRegistry() {
|
/**
|
||||||
return instance.registry;
|
* This returns our {@link NetworkManager} which is responsible
|
||||||
}
|
* for handling the Cargo and Energy networks.
|
||||||
|
*
|
||||||
|
* @return Our {@link NetworkManager} instance
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
public static NetworkManager getNetworkManager() {
|
public static NetworkManager getNetworkManager() {
|
||||||
|
validateInstance();
|
||||||
return instance.networkManager;
|
return instance.networkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static SlimefunRegistry getRegistry() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static GrapplingHookListener getGrapplingHookListener() {
|
public static GrapplingHookListener getGrapplingHookListener() {
|
||||||
|
validateInstance();
|
||||||
return instance.grapplingHookListener;
|
return instance.grapplingHookListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static BackpackListener getBackpackListener() {
|
public static BackpackListener getBackpackListener() {
|
||||||
|
validateInstance();
|
||||||
return instance.backpackListener;
|
return instance.backpackListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public static SlimefunBowListener getBowListener() {
|
public static SlimefunBowListener getBowListener() {
|
||||||
|
validateInstance();
|
||||||
return instance.bowListener;
|
return instance.bowListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Command} that was added by Slimefun.
|
||||||
|
*
|
||||||
|
* @return Slimefun's command
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static SlimefunCommand getCommand() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.command;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns our instance of the {@link SlimefunProfiler}, a tool that is used
|
||||||
|
* to analyse performance and lag.
|
||||||
|
*
|
||||||
|
* @return The {@link SlimefunProfiler}
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static SlimefunProfiler getProfiler() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.profiler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the currently installed version of Minecraft.
|
||||||
|
*
|
||||||
|
* @return The current version of Minecraft
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public static MinecraftVersion getMinecraftVersion() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.minecraftVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns whether this version of Slimefun was newly installed.
|
||||||
|
* It will return true if this {@link Server} uses Slimefun for the very first time.
|
||||||
|
*
|
||||||
|
* @return Whether this is a new installation of Slimefun
|
||||||
|
*/
|
||||||
|
public static boolean isNewlyInstalled() {
|
||||||
|
validateInstance();
|
||||||
|
return instance.isNewlyInstalled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
|
public static String getCSCoreLibVersion() {
|
||||||
|
validateInstance();
|
||||||
|
Plugin cscorelib = instance.getServer().getPluginManager().getPlugin("CS-CoreLib");
|
||||||
|
|
||||||
|
if (cscorelib == null) {
|
||||||
|
throw new IllegalStateException("CS-CoreLib is not installed.");
|
||||||
|
} else {
|
||||||
|
return cscorelib.getDescription().getVersion();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns a {@link Set} of every {@link Plugin} that lists Slimefun
|
* This method returns a {@link Set} of every {@link Plugin} that lists Slimefun
|
||||||
* as a required or optional dependency.
|
* as a required or optional dependency.
|
||||||
@ -753,66 +999,17 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
|
|||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Set<Plugin> getInstalledAddons() {
|
public static Set<Plugin> getInstalledAddons() {
|
||||||
return Arrays.stream(instance.getServer().getPluginManager().getPlugins()).filter(plugin -> plugin.getDescription().getDepend().contains(instance.getName()) || plugin.getDescription().getSoftDepend().contains(instance.getName())).collect(Collectors.toSet());
|
validateInstance();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
String pluginName = instance.getName();
|
||||||
* The {@link Command} that was added by Slimefun.
|
|
||||||
*
|
|
||||||
* @return Slimefun's command
|
|
||||||
*/
|
|
||||||
public static SlimefunCommand getCommand() {
|
|
||||||
return instance.command;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
// @formatter:off
|
||||||
* This returns our instance of the {@link SlimefunProfiler}, a tool that is used
|
return Arrays.stream(instance.getServer().getPluginManager().getPlugins())
|
||||||
* to analyse performance and lag.
|
.filter(plugin -> {
|
||||||
*
|
PluginDescriptionFile description = plugin.getDescription();
|
||||||
* @return The {@link SlimefunProfiler}
|
return description.getDepend().contains(pluginName) || description.getSoftDepend().contains(pluginName);
|
||||||
*/
|
}).collect(Collectors.toSet());
|
||||||
public static SlimefunProfiler getProfiler() {
|
// @formatter:on
|
||||||
return instance.profiler;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This returns the currently installed version of Minecraft.
|
|
||||||
*
|
|
||||||
* @return The current version of Minecraft
|
|
||||||
*/
|
|
||||||
public static MinecraftVersion getMinecraftVersion() {
|
|
||||||
return instance.minecraftVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method returns whether this version of Slimefun was newly installed.
|
|
||||||
* It will return true if this {@link Server} uses Slimefun for the very first time.
|
|
||||||
*
|
|
||||||
* @return Whether this is a new installation of Slimefun
|
|
||||||
*/
|
|
||||||
public static boolean isNewlyInstalled() {
|
|
||||||
return instance.isNewlyInstalled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
public static String getCSCoreLibVersion() {
|
|
||||||
Plugin cscorelib = instance.getServer().getPluginManager().getPlugin("CS-CoreLib");
|
|
||||||
|
|
||||||
if (cscorelib == null) {
|
|
||||||
throw new IllegalStateException("CS-CoreLib is not installed.");
|
|
||||||
} else {
|
|
||||||
return cscorelib.getDescription().getVersion();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaPlugin getJavaPlugin() {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getBugTrackerURL() {
|
|
||||||
return "https://github.com/Slimefun/Slimefun4/issues";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,253 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.guide;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ChatComponent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.CustomBookInterface;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link BookSlimefunGuide} is a {@link SlimefunGuideImplementation} which
|
|
||||||
* uses a {@link CustomBookInterface} to display the contents of the {@link SlimefunGuide}.
|
|
||||||
* {@link Player Players} have the option to choose this Written Book layout over the
|
|
||||||
* standard {@link Inventory} variant.
|
|
||||||
*
|
|
||||||
* @author TheBusyBiscuit
|
|
||||||
*
|
|
||||||
* @see SlimefunGuide
|
|
||||||
* @see SlimefunGuideImplementation
|
|
||||||
* @see ChestSlimefunGuide
|
|
||||||
* @see CheatSheetSlimefunGuide
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class BookSlimefunGuide implements SlimefunGuideImplementation {
|
|
||||||
|
|
||||||
private final NamespacedKey guideSearch = new NamespacedKey(SlimefunPlugin.instance(), "search");
|
|
||||||
private final ItemStack item;
|
|
||||||
|
|
||||||
public BookSlimefunGuide() {
|
|
||||||
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Book GUI)");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SlimefunGuideLayout getLayout() {
|
|
||||||
return SlimefunGuideLayout.BOOK;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSurvivalMode() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getItem() {
|
|
||||||
return item;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void openBook(Player p, PlayerProfile profile, List<ChatComponent> lines, boolean backButton) {
|
|
||||||
CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
|
|
||||||
book.setTitle(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
|
|
||||||
|
|
||||||
for (int i = 0; i < lines.size(); i = i + 10) {
|
|
||||||
ChatComponent page = new ChatComponent("");
|
|
||||||
ChatComponent header = new ChatComponent(ChatColors.color("&b&l- " + SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main") + " -\n\n"));
|
|
||||||
header.setHoverEvent(new HoverEvent(ChestMenuUtils.getSearchButton(p)));
|
|
||||||
|
|
||||||
header.setClickEvent(new ClickEvent(guideSearch, player -> SlimefunPlugin.runSync(() -> {
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(player, "guide.search.message");
|
|
||||||
ChatInput.waitForPlayer(SlimefunPlugin.instance(), player, msg -> SlimefunGuide.openSearch(profile, msg, true, true));
|
|
||||||
}, 1)));
|
|
||||||
|
|
||||||
page.append(header);
|
|
||||||
|
|
||||||
for (int j = i; j < lines.size() && j < i + 10; j++) {
|
|
||||||
page.append(lines.get(j));
|
|
||||||
}
|
|
||||||
|
|
||||||
page.append(new ChatComponent("\n"));
|
|
||||||
|
|
||||||
if (backButton) {
|
|
||||||
ChatComponent button = new ChatComponent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"));
|
|
||||||
button.setHoverEvent(new HoverEvent(ChatColor.DARK_BLUE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.title"), "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")));
|
|
||||||
button.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), "slimefun_guide"), pl -> openMainMenu(profile, 1)));
|
|
||||||
page.append(button);
|
|
||||||
}
|
|
||||||
|
|
||||||
book.addPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
book.open(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openMainMenu(PlayerProfile profile, int page) {
|
|
||||||
Player p = profile.getPlayer();
|
|
||||||
|
|
||||||
if (p == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<ChatComponent> lines = new LinkedList<>();
|
|
||||||
int tier = 0;
|
|
||||||
|
|
||||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
|
||||||
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) {
|
|
||||||
if (tier < category.getTier()) {
|
|
||||||
tier = category.getTier();
|
|
||||||
|
|
||||||
if (tier > 1) {
|
|
||||||
for (int i = 0; i < 10 && lines.size() % 10 != 0; i++) {
|
|
||||||
lines.add(new ChatComponent("\n"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lines.add(new ChatComponent(ChatColor.DARK_GRAY + "\u21E8" + ChatColor.DARK_BLUE + " Tier " + tier + "\n"));
|
|
||||||
}
|
|
||||||
|
|
||||||
addCategory(p, profile, category, lines);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
openBook(p, profile, lines, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addCategory(Player p, PlayerProfile profile, Category category, List<ChatComponent> lines) {
|
|
||||||
if (category instanceof LockedCategory && !((LockedCategory) category).hasUnlocked(p, profile)) {
|
|
||||||
List<String> lore = new LinkedList<>();
|
|
||||||
lore.add(ChatColor.DARK_RED + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked") + " " + ChatColor.GRAY + "- " + ChatColor.RESET + category.getItem(p).getItemMeta().getDisplayName());
|
|
||||||
lore.add("");
|
|
||||||
|
|
||||||
for (String line : SlimefunPlugin.getLocalization().getMessages(p, "guide.locked-category")) {
|
|
||||||
lore.add(ChatColor.RESET + line);
|
|
||||||
}
|
|
||||||
|
|
||||||
lore.add("");
|
|
||||||
|
|
||||||
for (Category parent : ((LockedCategory) category).getParents()) {
|
|
||||||
lore.add(parent.getItem(p).getItemMeta().getDisplayName());
|
|
||||||
}
|
|
||||||
|
|
||||||
ChatComponent chatComponent = new ChatComponent(ChatUtils.crop(ChatColor.RED, ItemUtils.getItemName(category.getItem(p))) + "\n");
|
|
||||||
chatComponent.setHoverEvent(new HoverEvent(lore));
|
|
||||||
lines.add(chatComponent);
|
|
||||||
} else {
|
|
||||||
ChatComponent chatComponent = new ChatComponent(ChatUtils.crop(ChatColor.DARK_GREEN, ItemUtils.getItemName(category.getItem(p))) + "\n");
|
|
||||||
chatComponent.setHoverEvent(new HoverEvent(ItemUtils.getItemName(category.getItem(p)), "", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
|
||||||
chatComponent.setClickEvent(new ClickEvent(category.getKey(), pl -> openCategory(profile, category, 1)));
|
|
||||||
lines.add(chatComponent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openCategory(PlayerProfile profile, Category category, int page) {
|
|
||||||
Player p = profile.getPlayer();
|
|
||||||
|
|
||||||
if (p == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (category instanceof FlexCategory) {
|
|
||||||
((FlexCategory) category).open(p, profile, getLayout());
|
|
||||||
} else if (category.getItems().size() < 250) {
|
|
||||||
profile.getGuideHistory().add(category, page);
|
|
||||||
|
|
||||||
List<ChatComponent> items = new LinkedList<>();
|
|
||||||
|
|
||||||
for (SlimefunItem slimefunItem : category.getItems()) {
|
|
||||||
if (Slimefun.hasPermission(p, slimefunItem, false)) {
|
|
||||||
if (Slimefun.isEnabled(p, slimefunItem, false)) {
|
|
||||||
addSlimefunItem(category, page, p, profile, slimefunItem, items);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.DARK_RED, ItemUtils.getItemName(slimefunItem.getItem())) + "\n");
|
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(ChatColor.DARK_RED + ChatColor.stripColor(ItemUtils.getItemName(slimefunItem.getItem())));
|
|
||||||
lore.add("");
|
|
||||||
|
|
||||||
for (String line : SlimefunPlugin.getPermissionsService().getLore(slimefunItem)) {
|
|
||||||
lore.add(ChatColors.color(line));
|
|
||||||
}
|
|
||||||
|
|
||||||
component.setHoverEvent(new HoverEvent(lore));
|
|
||||||
items.add(component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
openBook(p, profile, items, true);
|
|
||||||
} else {
|
|
||||||
p.sendMessage(ChatColor.RED + "That Category is too big to open :/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addSlimefunItem(Category category, int page, Player p, PlayerProfile profile, SlimefunItem item, List<ChatComponent> items) {
|
|
||||||
NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), item.getId().toLowerCase(Locale.ROOT));
|
|
||||||
|
|
||||||
if (!item.canUse(p, false) && item.hasResearch()) {
|
|
||||||
Research research = item.getResearch();
|
|
||||||
|
|
||||||
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.RED, item.getItemName()) + "\n");
|
|
||||||
component.setHoverEvent(new HoverEvent(ChatColor.RESET + item.getItemName(), ChatColor.DARK_RED.toString() + ChatColor.BOLD + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", ChatColor.GREEN + "> Click to unlock", "", ChatColor.GRAY + "Cost: " + ChatColor.AQUA.toString() + research.getCost() + " Level(s)"));
|
|
||||||
component.setClickEvent(new ClickEvent(key, player -> SlimefunPlugin.runSync(() -> research.unlockFromGuide(this, player, profile, item, category, page))));
|
|
||||||
|
|
||||||
items.add(component);
|
|
||||||
} else {
|
|
||||||
ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.DARK_GREEN, item.getItemName()) + "\n");
|
|
||||||
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
lore.add(item.getItemName());
|
|
||||||
|
|
||||||
if (item.getItem().hasItemMeta() && item.getItem().getItemMeta().hasLore()) {
|
|
||||||
lore.addAll(item.getItem().getItemMeta().getLore());
|
|
||||||
}
|
|
||||||
|
|
||||||
component.setHoverEvent(new HoverEvent(lore));
|
|
||||||
component.setClickEvent(new ClickEvent(key, player -> SlimefunPlugin.runSync(() -> displayItem(profile, item, true))));
|
|
||||||
items.add(component);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void openSearch(PlayerProfile profile, String input, boolean addToHistory) {
|
|
||||||
// We need to write a book implementation for this at some point
|
|
||||||
SlimefunGuide.openSearch(profile, input, true, addToHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
|
|
||||||
SlimefunGuide.displayItem(profile, item, addToHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
|
||||||
SlimefunGuide.displayItem(profile, item, addToHistory);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ import org.bukkit.inventory.Recipe;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
||||||
@ -21,13 +21,13 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is an admin-variant of the {@link ChestSlimefunGuide} which allows a {@link Player}
|
* This is an admin-variant of the {@link SurvivalSlimefunGuide} which allows a {@link Player}
|
||||||
* to spawn in a {@link SlimefunItem} via click rather than showing their {@link Recipe}.
|
* to spawn in a {@link SlimefunItem} via click rather than showing their {@link Recipe}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
|
||||||
|
|
||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
|
|
||||||
@ -37,11 +37,6 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
|||||||
item = new SlimefunGuideItem(this, "&cSlimefun Guide &4(Cheat Sheet)");
|
item = new SlimefunGuideItem(this, "&cSlimefun Guide &4(Cheat Sheet)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSurvivalMode() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display.
|
* Returns a {@link List} of visible {@link Category} instances that the {@link SlimefunGuide} would display.
|
||||||
*
|
*
|
||||||
@ -65,11 +60,13 @@ public class CheatSheetSlimefunGuide extends ChestSlimefunGuide {
|
|||||||
return categories;
|
return categories;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideLayout getLayout() {
|
public SlimefunGuideMode getMode() {
|
||||||
return SlimefunGuideLayout.CHEAT_SHEET;
|
return SlimefunGuideMode.CHEAT_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
return item;
|
return item;
|
||||||
|
@ -21,7 +21,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|||||||
* A {@link RecipeChoiceTask} is an asynchronously repeating task that cycles
|
* A {@link RecipeChoiceTask} is an asynchronously repeating task that cycles
|
||||||
* through the different variants of {@link Material} that a {@link MaterialChoice} or {@link Tag} can represent.
|
* through the different variants of {@link Material} that a {@link MaterialChoice} or {@link Tag} can represent.
|
||||||
*
|
*
|
||||||
* It is used in the {@link ChestSlimefunGuide} for any {@link ItemStack} from Minecraft
|
* It is used in the {@link SurvivalSlimefunGuide} for any {@link ItemStack} from Minecraft
|
||||||
* that accepts more than one {@link Material} in its {@link Recipe}.
|
* that accepts more than one {@link Material} in its {@link Recipe}.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
|
@ -27,6 +27,7 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
|
||||||
@ -34,7 +35,7 @@ import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
|||||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||||
@ -51,18 +52,17 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
|||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ChestSlimefunGuide} is the standard version of our {@link SlimefunGuide}.
|
* The {@link SurvivalSlimefunGuide} is the standard version of our {@link SlimefunGuide}.
|
||||||
* It uses an {@link Inventory} to display {@link SlimefunGuide} contents.
|
* It uses an {@link Inventory} to display {@link SlimefunGuide} contents.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
* @see SlimefunGuide
|
* @see SlimefunGuide
|
||||||
* @see SlimefunGuideImplementation
|
* @see SlimefunGuideImplementation
|
||||||
* @see BookSlimefunGuide
|
|
||||||
* @see CheatSheetSlimefunGuide
|
* @see CheatSheetSlimefunGuide
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
|
||||||
|
|
||||||
private static final int CATEGORY_SIZE = 36;
|
private static final int CATEGORY_SIZE = 36;
|
||||||
private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN;
|
private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN;
|
||||||
@ -71,14 +71,14 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
private final ItemStack item;
|
private final ItemStack item;
|
||||||
private final boolean showVanillaRecipes;
|
private final boolean showVanillaRecipes;
|
||||||
|
|
||||||
public ChestSlimefunGuide(boolean showVanillaRecipes) {
|
public SurvivalSlimefunGuide(boolean showVanillaRecipes) {
|
||||||
this.showVanillaRecipes = showVanillaRecipes;
|
this.showVanillaRecipes = showVanillaRecipes;
|
||||||
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
|
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SlimefunGuideLayout getLayout() {
|
public SlimefunGuideMode getMode() {
|
||||||
return SlimefunGuideLayout.CHEST;
|
return SlimefunGuideMode.SURVIVAL_MODE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -86,9 +86,8 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected final boolean isSurvivalMode() {
|
||||||
public boolean isSurvivalMode() {
|
return getMode() != SlimefunGuideMode.CHEAT_MODE;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -105,9 +104,19 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
List<Category> categories = new LinkedList<>();
|
List<Category> categories = new LinkedList<>();
|
||||||
|
|
||||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||||
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getLayout()))) {
|
try {
|
||||||
|
if (!category.isHidden(p) && (!(category instanceof FlexCategory) || ((FlexCategory) category).isVisible(p, profile, getMode()))) {
|
||||||
categories.add(category);
|
categories.add(category);
|
||||||
}
|
}
|
||||||
|
} catch (Exception | LinkageError x) {
|
||||||
|
SlimefunAddon addon = category.getAddon();
|
||||||
|
|
||||||
|
if (addon != null) {
|
||||||
|
addon.getLogger().log(Level.SEVERE, x, () -> "Could not display Category: " + category);
|
||||||
|
} else {
|
||||||
|
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "Could not display Category: " + category);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return categories;
|
return categories;
|
||||||
@ -204,7 +213,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (category instanceof FlexCategory) {
|
if (category instanceof FlexCategory) {
|
||||||
((FlexCategory) category).open(p, profile, getLayout());
|
((FlexCategory) category).open(p, profile, getMode());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -561,7 +570,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
pl.closeInventory();
|
pl.closeInventory();
|
||||||
|
|
||||||
SlimefunPlugin.getLocalization().sendMessage(pl, "guide.search.message");
|
SlimefunPlugin.getLocalization().sendMessage(pl, "guide.search.message");
|
||||||
ChatInput.waitForPlayer(SlimefunPlugin.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, isSurvivalMode(), isSurvivalMode()));
|
ChatInput.waitForPlayer(SlimefunPlugin.instance(), pl, msg -> SlimefunGuide.openSearch(profile, msg, getMode(), isSurvivalMode()));
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -698,7 +707,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
|
|
||||||
private void printErrorMessage(Player p, Throwable x) {
|
private void printErrorMessage(Player p, Throwable x) {
|
||||||
p.sendMessage(ChatColor.DARK_RED + "An internal server error has occurred. Please inform an admin, check the console for further info.");
|
p.sendMessage(ChatColor.DARK_RED + "An internal server error has occurred. Please inform an admin, check the console for further info.");
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An error has occurred while trying to open a SlimefunItem in the guide!", x);
|
SlimefunPlugin.logger().log(Level.SEVERE, "An error has occurred while trying to open a SlimefunItem in the guide!", x);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,55 +0,0 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
|
||||||
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
|
||||||
|
|
||||||
import org.bukkit.Effect;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The {@link AdvancedFarmerAndroid} is an extension of the {@link FarmerAndroid}.
|
|
||||||
* It also allows the {@link Player} to harvest plants from the addon ExoticGarden.
|
|
||||||
*
|
|
||||||
* @author John000708
|
|
||||||
* @author TheBusyBiscuit
|
|
||||||
*
|
|
||||||
* @see FarmerAndroid
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public class AdvancedFarmerAndroid extends FarmerAndroid {
|
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
|
||||||
public AdvancedFarmerAndroid(Category category, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
|
||||||
super(category, tier, item, recipeType, recipe);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public AndroidType getAndroidType() {
|
|
||||||
return AndroidType.ADVANCED_FARMER;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void exoticFarm(BlockMenu menu, Block block) {
|
|
||||||
farm(menu, block);
|
|
||||||
|
|
||||||
if (SlimefunPlugin.getIntegrations().isExoticGardenInstalled()) {
|
|
||||||
Optional<ItemStack> result = SlimefunPlugin.getThirdPartySupportService().harvestExoticGardenPlant(block);
|
|
||||||
|
|
||||||
if (result.isPresent()) {
|
|
||||||
ItemStack drop = result.get();
|
|
||||||
menu.pushItem(drop, getOutputSlots());
|
|
||||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -29,7 +29,7 @@ public enum AndroidType {
|
|||||||
FARMER,
|
FARMER,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link AdvancedFarmerAndroid} is an extension of the {@link FarmerAndroid},
|
* The Advanced Farmer is an extension of the {@link FarmerAndroid},
|
||||||
* it can also harvest plants from ExoticGarden.
|
* it can also harvest plants from ExoticGarden.
|
||||||
*/
|
*/
|
||||||
ADVANCED_FARMER,
|
ADVANCED_FARMER,
|
||||||
|
@ -3,6 +3,9 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -10,6 +13,7 @@ import org.bukkit.block.data.Ageable;
|
|||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.AndroidFarmEvent;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
@ -17,37 +21,41 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|||||||
|
|
||||||
public class FarmerAndroid extends ProgrammableAndroid {
|
public class FarmerAndroid extends ProgrammableAndroid {
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public FarmerAndroid(Category category, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public FarmerAndroid(Category category, int tier, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, tier, item, recipeType, recipe);
|
super(category, tier, item, recipeType, recipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AndroidType getAndroidType() {
|
public AndroidType getAndroidType() {
|
||||||
return AndroidType.FARMER;
|
return getTier() == 1 ? AndroidType.FARMER : AndroidType.ADVANCED_FARMER;
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isFullGrown(Block block) {
|
|
||||||
BlockData data = block.getBlockData();
|
|
||||||
|
|
||||||
if (!(data instanceof Ageable)) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ageable ageable = (Ageable) data;
|
|
||||||
return ageable.getAge() >= ageable.getMaximumAge();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void farm(BlockMenu menu, Block block) {
|
protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) {
|
||||||
if (isFullGrown(block)) {
|
Material blockType = block.getType();
|
||||||
ItemStack drop = getDropFromCrop(block.getType());
|
BlockData data = block.getBlockData();
|
||||||
|
ItemStack drop = null;
|
||||||
|
|
||||||
if (drop != null && menu.fits(drop, getOutputSlots())) {
|
if (data instanceof Ageable && ((Ageable) data).getAge() >= ((Ageable) data).getMaximumAge()) {
|
||||||
menu.pushItem(drop, getOutputSlots());
|
drop = getDropFromCrop(blockType);
|
||||||
Ageable ageable = (Ageable) block.getBlockData();
|
}
|
||||||
ageable.setAge(0);
|
|
||||||
block.setBlockData(ageable);
|
AndroidInstance instance = new AndroidInstance(this, b);
|
||||||
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
|
|
||||||
|
AndroidFarmEvent event = new AndroidFarmEvent(block, instance, isAdvanced, drop);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
|
if (!event.isCancelled()) {
|
||||||
|
drop = event.getDrop();
|
||||||
|
|
||||||
|
if (drop != null && menu.pushItem(drop, getOutputSlots()) == null) {
|
||||||
|
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, blockType);
|
||||||
|
|
||||||
|
if (data instanceof Ageable) {
|
||||||
|
((Ageable) data).setAge(0);
|
||||||
|
block.setBlockData(data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -191,7 +192,7 @@ public enum Instruction {
|
|||||||
*/
|
*/
|
||||||
FARM_FORWARD(AndroidType.FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> {
|
FARM_FORWARD(AndroidType.FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> {
|
||||||
Block target = b.getRelative(face);
|
Block target = b.getRelative(face);
|
||||||
android.farm(inv, target);
|
android.farm(b, inv, target, false);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,7 +201,7 @@ public enum Instruction {
|
|||||||
*/
|
*/
|
||||||
FARM_DOWN(AndroidType.FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> {
|
FARM_DOWN(AndroidType.FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> {
|
||||||
Block target = b.getRelative(BlockFace.DOWN);
|
Block target = b.getRelative(BlockFace.DOWN);
|
||||||
android.farm(inv, target);
|
android.farm(b, inv, target, false);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,7 +212,7 @@ public enum Instruction {
|
|||||||
*/
|
*/
|
||||||
FARM_EXOTIC_FORWARD(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> {
|
FARM_EXOTIC_FORWARD(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> {
|
||||||
Block target = b.getRelative(face);
|
Block target = b.getRelative(face);
|
||||||
android.exoticFarm(inv, target);
|
android.farm(b, inv, target, true);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -222,7 +223,7 @@ public enum Instruction {
|
|||||||
*/
|
*/
|
||||||
FARM_EXOTIC_DOWN(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> {
|
FARM_EXOTIC_DOWN(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> {
|
||||||
Block target = b.getRelative(BlockFace.DOWN);
|
Block target = b.getRelative(BlockFace.DOWN);
|
||||||
android.exoticFarm(inv, target);
|
android.farm(b, inv, target, true);
|
||||||
}),
|
}),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,7 +58,6 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
@ -425,7 +424,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
|||||||
openScriptEditor(player, b);
|
openScriptEditor(player, b);
|
||||||
}
|
}
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Exception was thrown when a User tried to download a Script!", x);
|
SlimefunPlugin.logger().log(Level.SEVERE, "An Exception was thrown when a User tried to download a Script!", x);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -673,6 +672,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
private void executeInstruction(Instruction instruction, Block b, BlockMenu inv, Config data, int index) {
|
private void executeInstruction(Instruction instruction, Block b, BlockMenu inv, Config data, int index) {
|
||||||
if (getAndroidType().isType(instruction.getRequiredType())) {
|
if (getAndroidType().isType(instruction.getRequiredType())) {
|
||||||
String rotationData = data.getString("rotation");
|
String rotationData = data.getString("rotation");
|
||||||
@ -830,14 +830,20 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
|||||||
preset.addItem(34, getFuelSource().getItem(), ChestMenuUtils.getEmptyClickHandler());
|
preset.addItem(34, getFuelSource().getItem(), ChestMenuUtils.getEmptyClickHandler());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
public void addItems(Block b, ItemStack... items) {
|
public void addItems(Block b, ItemStack... items) {
|
||||||
|
Validate.notNull(b, "The Block cannot be null.");
|
||||||
|
|
||||||
BlockMenu inv = BlockStorage.getInventory(b);
|
BlockMenu inv = BlockStorage.getInventory(b);
|
||||||
|
|
||||||
|
if (inv != null) {
|
||||||
for (ItemStack item : items) {
|
for (ItemStack item : items) {
|
||||||
inv.pushItem(item, getOutputSlots());
|
inv.pushItem(item, getOutputSlots());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParametersAreNonnullByDefault
|
||||||
protected void move(Block b, BlockFace face, Block block) {
|
protected void move(Block b, BlockFace face, Block block) {
|
||||||
if (block.getY() > 0 && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) {
|
if (block.getY() > 0 && block.getY() < block.getWorld().getMaxHeight() && block.isEmpty()) {
|
||||||
BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> {
|
BlockData blockData = Material.PLAYER_HEAD.createBlockData(data -> {
|
||||||
@ -875,11 +881,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
|
|||||||
throw new UnsupportedOperationException("Non-woodcutter Android tried to chop a Tree!");
|
throw new UnsupportedOperationException("Non-woodcutter Android tried to chop a Tree!");
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void farm(BlockMenu menu, Block block) {
|
protected void farm(Block b, BlockMenu menu, Block block, boolean isAdvanced) {
|
||||||
throw new UnsupportedOperationException("Non-farming Android tried to farm!");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void exoticFarm(BlockMenu menu, Block block) {
|
|
||||||
throw new UnsupportedOperationException("Non-farming Android tried to farm!");
|
throw new UnsupportedOperationException("Non-farming Android tried to farm!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,9 +21,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link Script} represents runnable code for a {@link ProgrammableAndroid}.
|
* A {@link Script} represents runnable code for a {@link ProgrammableAndroid}.
|
||||||
@ -244,7 +244,7 @@ public final class Script {
|
|||||||
scripts.add(new Script(config));
|
scripts.add(new Script(config));
|
||||||
}
|
}
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to load Android Script '" + file.getName() + "'");
|
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to load Android Script '" + file.getName() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,6 @@ public class StomperBoots extends SlimefunItem {
|
|||||||
* @return If the entity can move.
|
* @return If the entity can move.
|
||||||
*/
|
*/
|
||||||
protected boolean canPush(@Nonnull Player player, @Nonnull LivingEntity entity) {
|
protected boolean canPush(@Nonnull Player player, @Nonnull LivingEntity entity) {
|
||||||
return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId())
|
return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId()) && entity.isCollidable() && entity.hasGravity();
|
||||||
&& entity.isCollidable() && entity.hasGravity();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,12 +11,12 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
|
import io.github.thebusybiscuit.slimefun4.utils.holograms.SimpleHologram;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
@ -89,9 +89,9 @@ public class HologramProjector extends SlimefunItem {
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.addItem(1, new CustomItem(Material.CLOCK, "&7Offset: &e" + DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
menu.addItem(1, new CustomItem(Material.CLOCK, "&7Offset: &e" + NumberUtils.roundDecimalNumber(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + 1.0D), "", "&rLeft Click: &7+0.1", "&rRight Click: &7-0.1"));
|
||||||
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
|
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
|
||||||
double offset = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F));
|
double offset = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(projector.getLocation(), OFFSET_PARAMETER)) + (action.isRightClicked() ? -0.1F : 0.1F));
|
||||||
ArmorStand hologram = getArmorStand(projector, true);
|
ArmorStand hologram = getArmorStand(projector, true);
|
||||||
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
|
Location l = new Location(projector.getWorld(), projector.getX() + 0.5, projector.getY() + offset, projector.getZ() + 0.5);
|
||||||
hologram.teleport(l);
|
hologram.teleport(l);
|
||||||
|
@ -14,7 +14,6 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||||
@ -114,7 +113,7 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv
|
|||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
lore.add(ChatColors.color("&8\u21E8 &7Lasts " + NumberUtils.getTimeLeft(fuel.getTicks() / 2)));
|
lore.add(ChatColors.color("&8\u21E8 &7Lasts " + NumberUtils.getTimeLeft(fuel.getTicks() / 2)));
|
||||||
lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + getEnergyProduction() * 2) + " J/s");
|
lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + getEnergyProduction() * 2) + " J/s");
|
||||||
lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + DoubleHandler.getFancyDouble((double) fuel.getTicks() * getEnergyProduction()) + " J in total"));
|
lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + NumberUtils.getCompactDouble((double) fuel.getTicks() * getEnergyProduction()) + " J in total"));
|
||||||
im.setLore(lore);
|
im.setLore(lore);
|
||||||
item.setItemMeta(im);
|
item.setItemMeta(im);
|
||||||
list.add(item);
|
list.add(item);
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.math.DoubleHandler;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
|
||||||
@ -20,6 +19,7 @@ import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponen
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
@ -166,7 +166,7 @@ public abstract class AbstractEntityAssembler<T extends Entity> extends SimpleSl
|
|||||||
|
|
||||||
menu.replaceExistingItem(31, new CustomItem(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1"));
|
menu.replaceExistingItem(31, new CustomItem(Material.PISTON, "&7Offset: &3" + offset + " Block(s)", "", "&fLeft Click: &7+0.1", "&fRight Click: &7-0.1"));
|
||||||
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
menu.addMenuClickHandler(31, (p, slot, item, action) -> {
|
||||||
double offsetv = DoubleHandler.fixDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)) + (action.isRightClicked() ? -0.1F : 0.1F));
|
double offsetv = NumberUtils.reparseDouble(Double.valueOf(BlockStorage.getLocationInfo(b.getLocation(), KEY_OFFSET)) + (action.isRightClicked() ? -0.1F : 0.1F));
|
||||||
BlockStorage.addBlockInfo(b, KEY_OFFSET, String.valueOf(offsetv));
|
BlockStorage.addBlockInfo(b, KEY_OFFSET, String.valueOf(offsetv));
|
||||||
updateBlockInventory(menu, b);
|
updateBlockInventory(menu, b);
|
||||||
return false;
|
return false;
|
||||||
|
@ -12,12 +12,13 @@ import org.bukkit.potion.PotionData;
|
|||||||
import org.bukkit.potion.PotionType;
|
import org.bukkit.potion.PotionType;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
|
import io.github.thebusybiscuit.cscorelib2.inventory.InvUtils;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -26,7 +27,7 @@ import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
|||||||
* @author Linox
|
* @author Linox
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AutoBrewer extends AContainer {
|
public class AutoBrewer extends AContainer implements NotHopperable {
|
||||||
|
|
||||||
private static final Map<Material, PotionType> potionRecipes = new EnumMap<>(Material.class);
|
private static final Map<Material, PotionType> potionRecipes = new EnumMap<>(Material.class);
|
||||||
private static final Map<PotionType, PotionType> fermentations = new EnumMap<>(PotionType.class);
|
private static final Map<PotionType, PotionType> fermentations = new EnumMap<>(PotionType.class);
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
@ -22,7 +23,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
* @author Linox
|
* @author Linox
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class AutoDrier extends AContainer implements RecipeDisplayItem {
|
public class AutoDrier extends AContainer implements RecipeDisplayItem, NotHopperable {
|
||||||
|
|
||||||
private List<ItemStack> recipeList;
|
private List<ItemStack> recipeList;
|
||||||
|
|
||||||
|
@ -7,12 +7,13 @@ import org.bukkit.inventory.RecipeChoice;
|
|||||||
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
|
import org.bukkit.inventory.RecipeChoice.MaterialChoice;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
|
|
||||||
public class ElectricFurnace extends AContainer {
|
public class ElectricFurnace extends AContainer implements NotHopperable {
|
||||||
|
|
||||||
public ElectricFurnace(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public ElectricFurnace(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
@ -23,7 +24,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
* @see ElectricIngotFactory
|
* @see ElectricIngotFactory
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ElectricIngotPulverizer extends AContainer implements RecipeDisplayItem {
|
public class ElectricIngotPulverizer extends AContainer implements RecipeDisplayItem, NotHopperable {
|
||||||
|
|
||||||
public ElectricIngotPulverizer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public ElectricIngotPulverizer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
@ -3,13 +3,14 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
|
|
||||||
public class ElectricOreGrinder extends AContainer implements RecipeDisplayItem {
|
public class ElectricOreGrinder extends AContainer implements RecipeDisplayItem, NotHopperable {
|
||||||
|
|
||||||
public ElectricOreGrinder(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
public ElectricOreGrinder(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||||
super(category, item, recipeType, recipe);
|
super(category, item, recipeType, recipe);
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smeltery;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
@ -21,13 +22,13 @@ import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.AdvancedMenu
|
|||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
|
||||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||||
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
import me.mrCookieSlime.Slimefun.api.inventory.DirtyChestMenu;
|
||||||
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@link ElectricSmeltery} is an electric version of the standard {@link Smeltery}.
|
* The {@link ElectricSmeltery} is an electric version of the standard {@link Smeltery}.
|
||||||
@ -35,7 +36,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
|
|||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class ElectricSmeltery extends AContainer {
|
public class ElectricSmeltery extends AContainer implements NotHopperable {
|
||||||
|
|
||||||
private static final int[] border = { 4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44 };
|
private static final int[] border = { 4, 5, 6, 7, 8, 13, 31, 40, 41, 42, 43, 44 };
|
||||||
private static final int[] inputBorder = { 0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39 };
|
private static final int[] inputBorder = { 0, 1, 2, 3, 9, 12, 18, 21, 27, 30, 36, 37, 38, 39 };
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This represents an {@link ElevatorFloor} to which a {@link Player}
|
||||||
|
* can travel to using an {@link ElevatorPlate}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ElevatorFloor {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of this floor.
|
||||||
|
*/
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The floor number.
|
||||||
|
*/
|
||||||
|
private final int number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link Location} of this floor.
|
||||||
|
*/
|
||||||
|
private final Location location;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This constructs a new {@link ElevatorFloor} with the given name
|
||||||
|
* and the {@link Location} of the provided {@link Block}.
|
||||||
|
*
|
||||||
|
* @param name
|
||||||
|
* The name of this {@link ElevatorFloor}
|
||||||
|
* @param block
|
||||||
|
* The {@link Block} of this floor
|
||||||
|
*/
|
||||||
|
public ElevatorFloor(@Nonnull String name, int number, @Nonnull Block block) {
|
||||||
|
Validate.notNull(name, "An ElevatorFloor must have a name");
|
||||||
|
Validate.notNull(block, "An ElevatorFloor must have a block");
|
||||||
|
|
||||||
|
this.name = name;
|
||||||
|
this.number = number;
|
||||||
|
this.location = block.getLocation();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the name of this {@link ElevatorFloor}.
|
||||||
|
*
|
||||||
|
* @return The name of this floor
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link Location} of this {@link ElevatorFloor}.
|
||||||
|
*
|
||||||
|
* @return The {@link Location} of this floor
|
||||||
|
*/
|
||||||
|
@Nonnull
|
||||||
|
public Location getLocation() {
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the "altitude" of this floor.
|
||||||
|
* This is equivalent to the Y level of {@link #getLocation()}.
|
||||||
|
*
|
||||||
|
* @return The altitude of this floor
|
||||||
|
*/
|
||||||
|
public int getAltitude() {
|
||||||
|
return location.getBlockY();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the number of this floor.
|
||||||
|
* The lowest floor will have the number 0 and it
|
||||||
|
* increments from there.
|
||||||
|
*
|
||||||
|
* @return The number of this floor.
|
||||||
|
*/
|
||||||
|
public int getNumber() {
|
||||||
|
return number;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.gps;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@ -12,22 +12,19 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.NamespacedKey;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ChatComponent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.ClickEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.CustomBookInterface;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.json.HoverEvent;
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||||
@ -42,7 +39,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
* to teleport between them.
|
* to teleport between them.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
* @author Walshy
|
||||||
*/
|
*/
|
||||||
public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
||||||
|
|
||||||
@ -51,6 +48,11 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
*/
|
*/
|
||||||
private static final String DATA_KEY = "floor";
|
private static final String DATA_KEY = "floor";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is the size of our {@link Inventory}.
|
||||||
|
*/
|
||||||
|
private static final int GUI_SIZE = 27;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is our {@link Set} of currently teleporting {@link Player Players}.
|
* This is our {@link Set} of currently teleporting {@link Player Players}.
|
||||||
* It is used to prevent them from triggering the {@link ElevatorPlate} they land on.
|
* It is used to prevent them from triggering the {@link ElevatorPlate} they land on.
|
||||||
@ -77,6 +79,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public BlockUseHandler getItemHandler() {
|
public BlockUseHandler getItemHandler() {
|
||||||
return e -> {
|
return e -> {
|
||||||
@ -89,19 +92,24 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<Block> getFloors(@Nonnull Block b) {
|
public List<ElevatorFloor> getFloors(@Nonnull Block b) {
|
||||||
List<Block> floors = new LinkedList<>();
|
LinkedList<ElevatorFloor> floors = new LinkedList<>();
|
||||||
|
int index = 0;
|
||||||
|
|
||||||
for (int y = b.getWorld().getMaxHeight(); y > 0; y--) {
|
for (int y = 0; y < b.getWorld().getMaxHeight(); y++) {
|
||||||
if (y == b.getY()) {
|
if (y == b.getY()) {
|
||||||
floors.add(b);
|
String name = ChatColors.color(BlockStorage.getLocationInfo(b.getLocation(), DATA_KEY));
|
||||||
|
floors.addFirst(new ElevatorFloor(name, index, b));
|
||||||
|
index++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ());
|
Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ());
|
||||||
|
|
||||||
if (block.getType() == getItem().getType() && BlockStorage.check(block, getId())) {
|
if (block.getType() == getItem().getType() && BlockStorage.check(block, getId())) {
|
||||||
floors.add(block);
|
String name = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
|
||||||
|
floors.addFirst(new ElevatorFloor(name, index, block));
|
||||||
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,54 +122,69 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Block> floors = getFloors(b);
|
List<ElevatorFloor> floors = getFloors(b);
|
||||||
|
|
||||||
if (floors.size() < 2) {
|
if (floors.size() < 2) {
|
||||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
|
SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true);
|
||||||
} else {
|
} else {
|
||||||
openFloorSelector(b, floors, p);
|
openFloorSelector(b, floors, p, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void openFloorSelector(Block b, List<Block> floors, Player p) {
|
private void openFloorSelector(Block b, List<ElevatorFloor> floors, Player p, int page) {
|
||||||
CustomBookInterface book = new CustomBookInterface(SlimefunPlugin.instance());
|
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor"));
|
||||||
ChatComponent page = null;
|
menu.setEmptySlotsClickable(false);
|
||||||
|
|
||||||
for (int i = 0; i < floors.size(); i++) {
|
int index = GUI_SIZE * (page - 1);
|
||||||
if (i % 10 == 0) {
|
|
||||||
if (page != null) {
|
|
||||||
book.addPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
page = new ChatComponent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.pick-a-floor")) + "\n");
|
for (int i = 0; i < Math.min(GUI_SIZE, floors.size() - index); i++) {
|
||||||
}
|
ElevatorFloor floor = floors.get(index + i);
|
||||||
|
|
||||||
Block block = floors.get(i);
|
// @formatter:off
|
||||||
String floor = ChatColors.color(BlockStorage.getLocationInfo(block.getLocation(), DATA_KEY));
|
if (floor.getAltitude() == b.getY()) {
|
||||||
ChatComponent line;
|
menu.addItem(i, new CustomItem(
|
||||||
|
Material.COMPASS,
|
||||||
if (block.getY() == b.getY()) {
|
ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(),
|
||||||
line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor") + ' ' + ChatColor.WHITE + floor.getName()
|
||||||
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, ""));
|
), ChestMenuUtils.getEmptyClickHandler());
|
||||||
} else {
|
} else {
|
||||||
line = new ChatComponent("\n" + ChatColor.GRAY + (floors.size() - i) + ". " + ChatColor.BLACK + floor);
|
menu.addItem(i, new CustomItem(
|
||||||
line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.WHITE + floor, ""));
|
Material.PAPER,
|
||||||
line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> teleport(player, floor, block)));
|
ChatColor.GRAY.toString() + floor.getNumber() + ". " + ChatColor.BLACK + floor.getName(),
|
||||||
|
SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport") + ' ' + ChatColor.WHITE + floor.getName()
|
||||||
|
), (player, slot, itemStack, clickAction) -> {
|
||||||
|
teleport(player, floor);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// @formatter:on
|
||||||
}
|
}
|
||||||
|
|
||||||
page.append(line);
|
int pages = 1 + (floors.size() / GUI_SIZE);
|
||||||
|
|
||||||
|
// 0 index so size is the first slot of the last row.
|
||||||
|
for (int i = GUI_SIZE; i < GUI_SIZE + 9; i++) {
|
||||||
|
if (i == GUI_SIZE + 2 && pages > 1 && page != 1) {
|
||||||
|
menu.addItem(i, ChestMenuUtils.getPreviousButton(p, page, pages), (player, i1, itemStack, clickAction) -> {
|
||||||
|
openFloorSelector(b, floors, p, page - 1);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} else if (i == GUI_SIZE + 6 && pages > 1 && page != pages) {
|
||||||
|
menu.addItem(i, ChestMenuUtils.getNextButton(p, page, pages), (player, i1, itemStack, clickAction) -> {
|
||||||
|
openFloorSelector(b, floors, p, page + 1);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
menu.addItem(i, ChestMenuUtils.getBackground(), (player, i1, itemStack, clickAction) -> false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (page != null) {
|
menu.open(p);
|
||||||
book.addPage(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
book.open(p);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void teleport(Player player, String floorName, Block target) {
|
private void teleport(Player player, ElevatorFloor floor) {
|
||||||
SlimefunPlugin.runSync(() -> {
|
SlimefunPlugin.runSync(() -> {
|
||||||
users.add(player.getUniqueId());
|
users.add(player.getUniqueId());
|
||||||
|
|
||||||
@ -171,11 +194,12 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
|
|||||||
yaw = -180 + (yaw - 180);
|
yaw = -180 + (yaw - 180);
|
||||||
}
|
}
|
||||||
|
|
||||||
Location destination = new Location(player.getWorld(), target.getX() + 0.5, target.getY() + 0.4, target.getZ() + 0.5, yaw, player.getEyeLocation().getPitch());
|
Location loc = floor.getLocation();
|
||||||
|
Location destination = new Location(player.getWorld(), loc.getX() + 0.5, loc.getY() + 0.4, loc.getZ() + 0.5, yaw, player.getEyeLocation().getPitch());
|
||||||
|
|
||||||
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
|
PaperLib.teleportAsync(player, destination).thenAccept(teleported -> {
|
||||||
if (teleported.booleanValue()) {
|
if (teleported.booleanValue()) {
|
||||||
player.sendTitle(ChatColor.WHITE + ChatColors.color(floorName), null, 20, 60, 20);
|
player.sendTitle(ChatColor.WHITE + ChatColors.color(floor.getName()), null, 20, 60, 20);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
* This package holds the {@link io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate} and any
|
||||||
|
* related classes to making the elevator work.
|
||||||
|
*/
|
||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.items.elevator;
|
@ -17,8 +17,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment;
|
import io.github.thebusybiscuit.slimefun4.implementation.settings.TalismanEnchantment;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,7 +42,7 @@ public class MagicianTalisman extends Talisman {
|
|||||||
enchantments.add(new TalismanEnchantment(enchantment, i));
|
enchantments.add(new TalismanEnchantment(enchantment, i));
|
||||||
}
|
}
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, x, () -> "The following Exception occurred while trying to register the following Enchantment: " + enchantment);
|
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "The following Exception occurred while trying to register the following Enchantment: " + enchantment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,6 @@ import io.github.thebusybiscuit.cscorelib2.scheduling.TaskQueue;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This represents a running instance of an {@link IndustrialMiner}.
|
* This represents a running instance of an {@link IndustrialMiner}.
|
||||||
@ -198,7 +197,7 @@ class ActiveMiner implements Runnable {
|
|||||||
|
|
||||||
nextColumn();
|
nextColumn();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occurred while running an Industrial Miner at " + new BlockPosition(chest));
|
SlimefunPlugin.logger().log(Level.SEVERE, e, () -> "An Error occurred while running an Industrial Miner at " + new BlockPosition(chest));
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -350,7 +349,7 @@ class ActiveMiner implements Runnable {
|
|||||||
stop("machines.INDUSTRIAL_MINER.destroyed");
|
stop("machines.INDUSTRIAL_MINER.destroyed");
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, e, () -> "An Error occurred while moving a Piston for an Industrial Miner at " + new BlockPosition(block));
|
SlimefunPlugin.logger().log(Level.SEVERE, e, () -> "An Error occurred while moving a Piston for an Industrial Miner at " + new BlockPosition(block));
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
@ -50,7 +51,10 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|||||||
*/
|
*/
|
||||||
public class BlockListener implements Listener {
|
public class BlockListener implements Listener {
|
||||||
|
|
||||||
|
private final SlimefunPlugin plugin;
|
||||||
|
|
||||||
public BlockListener(@Nonnull SlimefunPlugin plugin) {
|
public BlockListener(@Nonnull SlimefunPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,19 +67,27 @@ public class BlockListener implements Listener {
|
|||||||
*/
|
*/
|
||||||
Block block = e.getBlock();
|
Block block = e.getBlock();
|
||||||
|
|
||||||
|
// Fixes #2636
|
||||||
if (e.getBlockReplacedState().getType().isAir()) {
|
if (e.getBlockReplacedState().getType().isAir()) {
|
||||||
SlimefunItem sfItem = BlockStorage.check(block);
|
SlimefunItem sfItem = BlockStorage.check(block);
|
||||||
|
|
||||||
// Fixes #2636
|
if (sfItem != null) {
|
||||||
if (sfItem != null && !SlimefunPlugin.getTickerTask().isDeletedSoon(block.getLocation())) {
|
/*
|
||||||
|
* We can move the TickerTask synchronization to an async task to
|
||||||
|
* avoid blocking the main Thread here.
|
||||||
|
*/
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
||||||
|
if (!SlimefunPlugin.getTickerTask().isDeletedSoon(block.getLocation())) {
|
||||||
for (ItemStack item : sfItem.getDrops()) {
|
for (ItemStack item : sfItem.getDrops()) {
|
||||||
if (item != null && !item.getType().isAir()) {
|
if (item != null && !item.getType().isAir()) {
|
||||||
block.getWorld().dropItemNaturally(block.getLocation(), item);
|
SlimefunPlugin.runSync(() -> block.getWorld().dropItemNaturally(block.getLocation(), item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockStorage.clearBlockInfo(block);
|
BlockStorage.clearBlockInfo(block);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
} else if (BlockStorage.hasBlockInfo(e.getBlock())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -158,10 +170,14 @@ public class BlockListener implements Listener {
|
|||||||
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
|
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
|
||||||
|
|
||||||
if (blockHandler != null) {
|
if (blockHandler != null) {
|
||||||
|
try {
|
||||||
if (!blockHandler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK)) {
|
if (!blockHandler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} catch (Exception | LinkageError x) {
|
||||||
|
sfItem.error("Something went wrong while triggering a BlockHandler", x);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onBlockBreak(e, item, fortune, drops));
|
sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onBlockBreak(e, item, fortune, drops));
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ public class BlockPhysicsListener implements Listener {
|
|||||||
Location loc = block.getLocation();
|
Location loc = block.getLocation();
|
||||||
|
|
||||||
// Fixes #2496 - Make sure it is not a moving block
|
// Fixes #2496 - Make sure it is not a moving block
|
||||||
if (SlimefunPlugin.getTickerTask().isReserved(loc)) {
|
if (SlimefunPlugin.getTickerTask().isOccupiedSoon(loc)) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,8 @@ public class ButcherAndroidListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Some items are not dropped by default. Wither Skeleton Skulls but for some weird reason
|
* Some items are not dropped by default.
|
||||||
|
* Wither Skeleton Skulls but for some weird reason
|
||||||
* even Blaze rods...
|
* even Blaze rods...
|
||||||
*
|
*
|
||||||
* @param drops
|
* @param drops
|
||||||
|
@ -6,6 +6,7 @@ import javax.annotation.Nonnull;
|
|||||||
import javax.annotation.ParametersAreNonnullByDefault;
|
import javax.annotation.ParametersAreNonnullByDefault;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
@ -28,7 +29,6 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
|||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This {@link Listener} is responsible for handling our debugging tool, the debug fish.
|
* This {@link Listener} is responsible for handling our debugging tool, the debug fish.
|
||||||
@ -86,14 +86,19 @@ public class DebugFishListener implements Listener {
|
|||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void onRightClick(Player p, Block b, BlockFace face) {
|
private void onRightClick(Player p, Block b, BlockFace face) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
|
// Fixes #2655 - Delaying the placement to prevent a new event from being fired
|
||||||
|
SlimefunPlugin.runSync(() -> {
|
||||||
Block block = b.getRelative(face);
|
Block block = b.getRelative(face);
|
||||||
block.setType(Material.PLAYER_HEAD);
|
block.setType(Material.PLAYER_HEAD);
|
||||||
SkullBlock.setFromHash(block, HeadTexture.MISSING_TEXTURE.getTexture());
|
SkullBlock.setFromHash(block, HeadTexture.MISSING_TEXTURE.getTexture());
|
||||||
|
|
||||||
|
p.playSound(block.getLocation(), Sound.BLOCK_BAMBOO_PLACE, 1, 1);
|
||||||
|
}, 2L);
|
||||||
} else if (BlockStorage.hasBlockInfo(b)) {
|
} else if (BlockStorage.hasBlockInfo(b)) {
|
||||||
try {
|
try {
|
||||||
sendInfo(p, b);
|
sendInfo(p, b);
|
||||||
} catch (Exception x) {
|
} catch (Exception x) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "An Exception occurred while using a Debug-Fish", x);
|
SlimefunPlugin.logger().log(Level.SEVERE, "An Exception occurred while using a Debug-Fish", x);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable;
|
||||||
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link Listener} prevents item from being transferred to
|
||||||
|
* and from {@link AContainer} using a hopper.
|
||||||
|
*
|
||||||
|
* @author CURVX
|
||||||
|
*
|
||||||
|
* @see NotHopperable
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class HopperListener implements Listener {
|
||||||
|
|
||||||
|
public HopperListener(@Nonnull SlimefunPlugin plugin) {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onHopperInsert(InventoryMoveItemEvent e) {
|
||||||
|
Location loc = e.getDestination().getLocation();
|
||||||
|
if (e.getSource().getType() == InventoryType.HOPPER && loc != null && BlockStorage.check(loc.getBlock()) instanceof NotHopperable) {
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,10 +12,10 @@ import org.bukkit.event.Listener;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.SlimefunGuideOpenEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
|
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||||
@ -38,7 +38,7 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SlimefunGuideLayout type = SlimefunGuide.getDefaultLayout();
|
SlimefunGuideMode type = SlimefunGuide.getDefaultMode();
|
||||||
p.getInventory().addItem(SlimefunGuide.getItem(type).clone());
|
p.getInventory().addItem(SlimefunGuide.getItem(type).clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,31 +47,27 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
public void onInteract(PlayerRightClickEvent e) {
|
public void onInteract(PlayerRightClickEvent e) {
|
||||||
Player p = e.getPlayer();
|
Player p = e.getPlayer();
|
||||||
|
|
||||||
if (tryOpenGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) {
|
if (tryOpenGuide(p, e, SlimefunGuideMode.SURVIVAL_MODE) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
} else {
|
} else {
|
||||||
openGuide(p, e, SlimefunGuideLayout.BOOK);
|
openGuide(p, e, SlimefunGuideMode.SURVIVAL_MODE);
|
||||||
}
|
}
|
||||||
} else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) {
|
} else if (tryOpenGuide(p, e, SlimefunGuideMode.CHEAT_MODE) == Result.ALLOW) {
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
SlimefunGuideSettings.openSettings(p, e.getItem());
|
||||||
} else {
|
} else {
|
||||||
openGuide(p, e, SlimefunGuideLayout.CHEST);
|
/*
|
||||||
}
|
* We rather just run the command here, all
|
||||||
} else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) {
|
* necessary permission checks will be handled there.
|
||||||
if (p.isSneaking()) {
|
*/
|
||||||
SlimefunGuideSettings.openSettings(p, e.getItem());
|
|
||||||
} else {
|
|
||||||
// We rather just run the command here,
|
|
||||||
// all necessary permission checks will be handled there.
|
|
||||||
p.chat("/sf cheat");
|
p.chat("/sf cheat");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideMode layout) {
|
||||||
SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout);
|
SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
@ -83,7 +79,7 @@ public class SlimefunGuideListener implements Listener {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ParametersAreNonnullByDefault
|
@ParametersAreNonnullByDefault
|
||||||
private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) {
|
private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideMode layout) {
|
||||||
ItemStack item = e.getItem();
|
ItemStack item = e.getItem();
|
||||||
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) {
|
if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) {
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.ElevatorPlate;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.Teleporter;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.world.WorldUnloadEvent;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
public class WorldListener implements Listener {
|
public class WorldListener implements Listener {
|
||||||
|
|
||||||
@ -32,7 +31,7 @@ public class WorldListener implements Listener {
|
|||||||
if (storage != null) {
|
if (storage != null) {
|
||||||
storage.saveAndRemove();
|
storage.saveAndRemove();
|
||||||
} else {
|
} else {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"{0}\"", e.getWorld().getName());
|
SlimefunPlugin.logger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"{0}\"", e.getWorld().getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,8 +3,16 @@ package io.github.thebusybiscuit.slimefun4.implementation.resources;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GEOResource} which consists of nether ice.
|
||||||
|
* It can only be found in the nether.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
class NetherIceResource extends SlimefunResource {
|
class NetherIceResource extends SlimefunResource {
|
||||||
|
|
||||||
NetherIceResource() {
|
NetherIceResource() {
|
||||||
|
@ -3,8 +3,21 @@ package io.github.thebusybiscuit.slimefun4.implementation.resources;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GEOResource} which consists of buckets of Oil.
|
||||||
|
* It cannot be obtained via a {@link GEOMiner} but instead requires
|
||||||
|
* and {@link OilPump}.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see OilPump
|
||||||
|
*
|
||||||
|
*/
|
||||||
class OilResource extends SlimefunResource {
|
class OilResource extends SlimefunResource {
|
||||||
|
|
||||||
OilResource() {
|
OilResource() {
|
||||||
|
@ -3,8 +3,15 @@ package io.github.thebusybiscuit.slimefun4.implementation.resources;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GEOResource} which consists of Salt.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
class SaltResource extends SlimefunResource {
|
class SaltResource extends SlimefunResource {
|
||||||
|
|
||||||
SaltResource() {
|
SaltResource() {
|
||||||
|
@ -10,6 +10,17 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is an abstract parent class for any {@link GEOResource}
|
||||||
|
* that is added by Slimefun itself. It is package-private, therefore
|
||||||
|
* only classes inside this package can access it.
|
||||||
|
* <p>
|
||||||
|
* It just provides a bit of a convenience for us to reduce redundancies
|
||||||
|
* in our {@link GEOResource} implementations.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
abstract class SlimefunResource implements GEOResource {
|
abstract class SlimefunResource implements GEOResource {
|
||||||
|
|
||||||
private final NamespacedKey key;
|
private final NamespacedKey key;
|
||||||
|
@ -3,8 +3,15 @@ package io.github.thebusybiscuit.slimefun4.implementation.resources;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link GEOResource} which consists of small chunks of Uranium.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
*/
|
||||||
class UraniumResource extends SlimefunResource {
|
class UraniumResource extends SlimefunResource {
|
||||||
|
|
||||||
UraniumResource() {
|
UraniumResource() {
|
||||||
|
@ -35,14 +35,13 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.Smelt
|
|||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
|
||||||
import me.mrCookieSlime.Slimefun.api.Slimefun;
|
|
||||||
|
|
||||||
public final class PostSetup {
|
public final class PostSetup {
|
||||||
|
|
||||||
private PostSetup() {}
|
private PostSetup() {}
|
||||||
|
|
||||||
public static void setupWiki() {
|
public static void setupWiki() {
|
||||||
Slimefun.getLogger().log(Level.INFO, "Loading Wiki pages...");
|
SlimefunPlugin.logger().log(Level.INFO, "Loading Wiki pages...");
|
||||||
JsonParser parser = new JsonParser();
|
JsonParser parser = new JsonParser();
|
||||||
|
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream("/wiki.json"), StandardCharsets.UTF_8))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(SlimefunPlugin.class.getResourceAsStream("/wiki.json"), StandardCharsets.UTF_8))) {
|
||||||
@ -57,7 +56,7 @@ public final class PostSetup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Slimefun.getLogger().log(Level.SEVERE, "Failed to load wiki.json file", e);
|
SlimefunPlugin.logger().log(Level.SEVERE, "Failed to load wiki.json file", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +67,7 @@ public final class PostSetup {
|
|||||||
SlimefunItem item = iterator.next();
|
SlimefunItem item = iterator.next();
|
||||||
|
|
||||||
if (item == null) {
|
if (item == null) {
|
||||||
Slimefun.getLogger().log(Level.WARNING, "Removed bugged Item ('NULL?')");
|
SlimefunPlugin.logger().log(Level.WARNING, "Removed bugged Item ('NULL?')");
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
@ -25,7 +25,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.RadioactiveItem;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AdvancedFarmerAndroid;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInterface;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInterface;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid;
|
||||||
@ -110,6 +109,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.XPCollector;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.XPCollector;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NetherStarReactor;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.NuclearReactor;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.elevator.ElevatorPlate;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
|
||||||
@ -122,7 +122,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
|||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.PortableGEOScanner;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.PortableGEOScanner;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.ElevatorPlate;
|
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSControlPanel;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSControlPanel;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSMarkerTool;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSMarkerTool;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
||||||
@ -1895,7 +1894,7 @@ public final class SlimefunItemSetup {
|
|||||||
new ItemStack[] {null, SlimefunItems.GPS_TRANSMITTER, null, new ItemStack(Material.DIAMOND_SWORD), SlimefunItems.PROGRAMMABLE_ANDROID_2, new ItemStack(Material.DIAMOND_SWORD), null, SlimefunItems.ELECTRIC_MOTOR, null})
|
new ItemStack[] {null, SlimefunItems.GPS_TRANSMITTER, null, new ItemStack(Material.DIAMOND_SWORD), SlimefunItems.PROGRAMMABLE_ANDROID_2, new ItemStack(Material.DIAMOND_SWORD), null, SlimefunItems.ELECTRIC_MOTOR, null})
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
|
||||||
new AdvancedFarmerAndroid(categories.androids, 2, SlimefunItems.PROGRAMMABLE_ANDROID_2_FARMER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
new FarmerAndroid(categories.androids, 2, SlimefunItems.PROGRAMMABLE_ANDROID_2_FARMER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||||
new ItemStack[] {null, SlimefunItems.GPS_TRANSMITTER, null, new ItemStack(Material.DIAMOND_HOE), SlimefunItems.PROGRAMMABLE_ANDROID_2, new ItemStack(Material.DIAMOND_HOE), null, SlimefunItems.ELECTRIC_MOTOR, null})
|
new ItemStack[] {null, SlimefunItems.GPS_TRANSMITTER, null, new ItemStack(Material.DIAMOND_HOE), SlimefunItems.PROGRAMMABLE_ANDROID_2, new ItemStack(Material.DIAMOND_HOE), null, SlimefunItems.ELECTRIC_MOTOR, null})
|
||||||
.register(plugin);
|
.register(plugin);
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user