diff --git a/.github/workflows/auto-approve.yml b/.github/workflows/auto-approve.yml index fd145561e..44a48b4df 100644 --- a/.github/workflows/auto-approve.yml +++ b/.github/workflows/auto-approve.yml @@ -20,3 +20,10 @@ jobs: if: github.actor == 'gitlocalize-app[bot]' || github.actor == 'renovate[bot]' with: github-token: "${{ secrets.ACCESS_TOKEN }}" + - name: Add Translations label + uses: maxkomarychev/octions/octions/issues/add-labels@master + if: github.actor == 'gitlocalize-app[bot]' + with: + token: ${{ secrets.ACCESS_TOKEN }} + issue_number: ${{ github.event.pull_request.number }} + labels: 'Translations Update' diff --git a/.github/workflows/imports-fix.yml b/.github/workflows/imports-fix.yml new file mode 100644 index 000000000..152437949 --- /dev/null +++ b/.github/workflows/imports-fix.yml @@ -0,0 +1,30 @@ +name: Clean up Imports + +on: + pull_request: + branches: + - master + paths: + - 'src/main/java/**' + +jobs: + build: + + name: Clean up Imports + runs-on: ubuntu-latest + if: $ {{ secrets.ACCESS_TOKEN }} != null + + steps: + - name: Checkout repository + uses: actions/checkout@v2.3.3 + - name: Set up JDK 1.8 + uses: actions/setup-java@v1.4.3 + with: + java-version: 11 + - name: Clean up Imports + uses: axel-op/googlejavaformat-action@v3.3.2 + with: + files: '**/*.java' + skipCommit: false + args: "--fix-imports-only --replace" + githubToken: $ {{ secrets.ACCESS_TOKEN }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 20b3c4609..a5f708932 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -35,11 +35,14 @@ * (API) Added SlimefunGuideOpenEvent * (API) Added "NotConfigurable" attribute to disable configurability * Added Elytra Cap +* Added Planks to Sticks recipe to the Table Saw +* Added "slimefun.gps.bypass" permission to open GPS devices anywhere #### Changes * Improved Auto-Updater (Multi-Threading and more) * General performance improvements * /sf cheat now shows seasonal categories all year through +* GPS devices now require chest-access in that area to be used #### Fixes * Fixed #2300 @@ -64,6 +67,7 @@ * Fixed radioactive items still being radioactive when disabled * Fixed #2391 * Fixed #2403 +* Fixed #2405 ## Release Candidate 16 (07 Sep 2020) https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e9d1e9120..03fd38e80 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -94,3 +94,93 @@ Then you should be able build it via Maven using the goals `clean package`. If you have any further questions, then please join our [Discord Support Server](https://discord.gg/slimefun) and ask your questions in the `#programming-help` channel.
**Note that we will not accept any bug reports from custom-compiled versions of Slimefun**. + +## :black_nib: Code Style guidelines +The general gist when it comes to code style: **Try to be consistent!**.
+Try to stay inline with the code that surrounds you, having an entire package or even a single file that's filled with plenty of different and inconsistent code styles is just hard to read or maintain. That's why we wanna make sure everyone follows these principles. + +*Note that these are just guidelines, we may request changes on your pull request if we think there are changes necessary. +But we won't reject your Pull Request completely due to a few styling inconsistencies, we can always refactor code later. +But do try to follow our code style as best as you can.* + +#### 1. Imports +* Don't use wildcard (`*`) imports! +* Don't import unused classes! +* Don't use static imports! +* Always use imports, even in javadocs, don't write out the full location of a class. +#### 2. Annotations +* Methods and parameters should be annotated with `@Nullable` (`javax.annotation.Nullable`) or `@Nonnull`(`javax.annotation.Nonnull`)! +* Methods that override a method must be annotated with `@Override`! +* Interfaces with only one method should be annotated using `@FunctionalInterface`! +* If you deprecate a method, add an `@deprecated` section to the javadocs explaining why you did it. +#### 3. Documentation +* Every class and every public method should have a Javadocs section assigned to it. +* New packages should have a `package-info.java` file with documentation about the package. +* Classes should have an `@author` tag. +* If there are any other relevant classes related to yours, add them using the `@see` tag. +#### 4. Unit Tests +* Try to write Unit Tests where possible. +* Unit Test classes and methods should have no access modifier, not `public`, `protected` nor `private`. +* Each Test should have a plain text `@DisplayName` annotation! +#### 5. General best-practices +* Do not use `Collection#forEach(x -> ...)`, use a proper `for (...)` loop! +* Do not create new `Random` objects, use `ThreadLocalRandom.current()` instead! +* Always declare Maps or Collections using their base type! (e.g. `List list = new ArrayList<>();`) +* When doing String operations like `String#toUppercase()`, always specify `Locale.ROOT` as an argument! +* When reading or writing files, always specify the encoding using `StandardCharsets.UTF_8`! +* Do not declare multiple fields/variables on the same line! (e.g. Don't do this: `int x, y, z;`) +* Use a Logger, try to avoid `System.out.println(...)` and `Throwable#printStacktrace()`, use `Logger#log` instead! +* Do not use Exceptions to validate data, empty catch blocks are a very bad practice, use other means like a regular expression to validate data. +* If a parameter is annotated with `@Nonnull`, you should enforce this behaviour by doing `Validate.notNull(variable, "...");` and give a meaningful message about what went wrong +* Any `switch/case` should always have a `default:` case at the end. +* If you are working with a resource that must be closed, use a `try/with-resource`, this will automatically close the resource at the end. (e.g. `try (InputStream stream = ...) {`) +* Array designators should be placed behind the type, not the variable name. (e.g. `int[] myArray`) +* Enums must be compared using `==`, not with `.equals()`! +* Avoid direct string concatenation, use a `StringBuilder` instead! +* If you need both the key and the value from a Map, use `Map#entrySet()`! +#### 6. Naming conventions +* Classes should be in *PascalCase* (e.g. `MyAwesomeClass`) +* Enum constants should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_ENUM_CONSTANT`) +* Constants (`static final` fields) should be in *SCREAMING_SNAKE_CASE* (e.g. `MY_CONSTANT_FIELD`) +* Variables, parameters and fields should be in *camelCase* (e.g. `myVariableOrField`) +* All methods should be in *camelCase* (e.g. `myMethod`) +* Packages must be all lowercase, consecutive words should generally be avoided. (e.g. `io.github.thebusybiscuit.slimefun4.core.something`) +#### 7. Style preferences +* Use **Spaces**, not Tabs! +* One class per file! Please don't put multiple classes into one file, this also applies to enums, make a seperate file for new classes or enums. +* Try to keep ternary operators to a minimum, only in return statements. (e.g. avoid doing this: `int y = x == null ? 1: 2`) +* Try to keep so-called "guard blocks" to a minimum. One guard block is fine but having multiple guard blocks before getting to the actual code... Well, you might wanna refactor your code there. Example: +```java +// guard block +if (something) { + return; +} + +// Actual code... +``` +* if/else statements should always include a bracket, please avoid one-line statements. (e.g. Avoid doing: `if (x == 0) return;`) +* We do not enforce any particular width or column limit, but try to prevent your lines from becoming too long. +* Annotations for methods or fields should never go on the same line, place them on the line above. +* Comments should never go on the same line as code! Always above or below. +* Make sure that empty lines are truly empty, they should not contain any whitespace characters. +* Empty blocks like constructors should not occupy more than one line. (e.g. `private MyClass() {}`) +* Modifiers for classes and fields must follow this order:
+`(public/protected/private) (abstract) (static) (final)` +* We recommend using horizontal whitespaces like this: + * In variable assignments: `int x = 123;` + * In a for-loop: `for (int i = 0; i < 10; i++) {` + * Before and after statement parenthesis: `if (x != null) {` + * Inbetween array initializers: `int[] array = { 1, 2, 3 };` + * After the double slash of a comment: `// This is a comment` +* Slimefun follows the **1TBS / OTBS** Bracket-Style standard (One true brace style): +```java +private void example(int x) { + if (x < 0) { + // x < 0 + } else if (x > 0) { + // x > 0 + } else { + // x == 0 + } +} +``` diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java index 873f5e221..2abcada1d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/ErrorReport.java @@ -182,8 +182,7 @@ public class ErrorReport { } addon.getLogger().log(Level.WARNING, ""); - } - catch (Exception x) { + } catch (Exception x) { addon.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving an Error-Report for Slimefun " + SlimefunPlugin.getVersion()); } } @@ -198,8 +197,7 @@ public class ErrorReport { if (plugin.getDescription().getDepend().contains(dependency) || plugin.getDescription().getSoftDepend().contains(dependency)) { addons.add(" + " + plugin.getName() + ' ' + plugin.getDescription().getVersion()); } - } - else { + } else { plugins.add(" - " + plugin.getName() + ' ' + plugin.getDescription().getVersion()); if (plugin.getDescription().getDepend().contains(dependency) || plugin.getDescription().getSoftDepend().contains(dependency)) { @@ -227,8 +225,7 @@ public class ErrorReport { public static void tryCatch(@Nonnull Function> function, @Nonnull Runnable runnable) { try { runnable.run(); - } - catch (Exception x) { + } catch (Exception x) { function.apply(x); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java index 1a129d96d..781bc0ef1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/BlockPlacerPlaceEvent.java @@ -79,8 +79,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { if (!locked) { this.placedItem = item; - } - else { + } else { SlimefunItem.getByItem(placedItem).warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!"); } } @@ -94,8 +93,7 @@ public class BlockPlacerPlaceEvent extends BlockEvent implements Cancellable { public void setCancelled(boolean cancel) { if (!locked) { cancelled = cancel; - } - else { + } else { SlimefunItem.getByItem(placedItem).warn("A BlockPlacerPlaceEvent cannot be modified from within a BlockPlaceHandler!"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java index d4375feae..1bfd42977 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/PlayerRightClickEvent.java @@ -47,8 +47,7 @@ public class PlayerRightClickEvent extends Event { if (e.getItem() == null || e.getItem().getType() == Material.AIR || e.getItem().getAmount() == 0) { itemStack = Optional.empty(); - } - else { + } else { itemStack = Optional.of(e.getItem()); } } @@ -101,8 +100,7 @@ public class PlayerRightClickEvent extends Event { if (!slimefunItem.isComputed()) { if (itemStack.isPresent()) { slimefunItem.compute(SlimefunItem.getByItem(itemStack.get())); - } - else { + } else { slimefunItem = ComputedOptional.empty(); } } @@ -115,8 +113,7 @@ public class PlayerRightClickEvent extends Event { if (!slimefunBlock.isComputed()) { if (clickedBlock.isPresent()) { slimefunBlock.compute(BlockStorage.check(clickedBlock.get())); - } - else { + } else { slimefunBlock = ComputedOptional.empty(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java index 77026b0ae..2fdbe469a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/events/SlimefunGuideOpenEvent.java @@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout; /** - * 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 * @@ -37,7 +37,7 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { } /** - * This returns the {@link Player} that tries to open + * This returns the {@link Player} that tries to open * the Slimefun Guide. * * @return The {@link Player} @@ -48,7 +48,7 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { } /** - * This returns the {@link ItemStack} that {@link Player} + * This returns the {@link ItemStack} that {@link Player} * tries to open the Slimefun Guide with. * * @return The {@link ItemStack} @@ -57,7 +57,7 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { public ItemStack getGuide() { return guide; } - + /** * This returns the {@link SlimefunGuideLayout} of the Slimefun Guide * that {@link Player} tries to open. @@ -68,12 +68,12 @@ public class SlimefunGuideOpenEvent extends Event implements Cancellable { public SlimefunGuideLayout getGuideLayout() { return layout; } - + /** * Changes the {@link SlimefunGuideLayout} that was tried to be opened with. * * @param layout - * The new {@link SlimefunGuideLayout} + * The new {@link SlimefunGuideLayout} */ public void setGuideLayout(@Nonnull SlimefunGuideLayout layout) { Validate.notNull(layout, "You must specify a layout that is not-null!"); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java index 792bb6de0..b8fcbc218 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/geo/ResourceManager.java @@ -104,8 +104,7 @@ public class ResourceManager { if (value != null) { return OptionalInt.of(Integer.parseInt(value)); - } - else { + } else { return OptionalInt.empty(); } } @@ -202,13 +201,15 @@ public class ResourceManager { menu.addItem(47, ChestMenuUtils.getPreviousButton(p, page + 1, pages)); menu.addMenuClickHandler(47, (pl, slot, item, action) -> { - if (page > 0) scan(pl, block, page - 1); + if (page > 0) + scan(pl, block, page - 1); return false; }); menu.addItem(51, ChestMenuUtils.getNextButton(p, page + 1, pages)); menu.addMenuClickHandler(51, (pl, slot, item, action) -> { - if (page + 1 < pages) scan(pl, block, page + 1); + if (page + 1 < pages) + scan(pl, block, page + 1); return false; }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java index e7507604e..1e7d7e311 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/GPSNetwork.java @@ -73,8 +73,7 @@ public class GPSNetwork { if (online) { set.add(l); - } - else { + } else { set.remove(l); } } @@ -118,8 +117,7 @@ public class GPSNetwork { public int countTransmitters(@Nonnull UUID uuid) { if (!transmitters.containsKey(uuid)) { return 0; - } - else { + } else { return transmitters.get(uuid).size(); } } @@ -150,7 +148,8 @@ public class GPSNetwork { int index = 0; for (Location l : getTransmitters(p.getUniqueId())) { - if (index >= inventory.length) break; + if (index >= inventory.length) + break; SlimefunItem sfi = BlockStorage.check(l); if (sfi instanceof GPSTransmitter) { @@ -185,14 +184,11 @@ public class GPSNetwork { public ItemStack getIcon(@Nonnull String name, @Nonnull Environment environment) { if (name.startsWith("player:death ")) { return HeadTexture.DEATHPOINT.getAsItemStack(); - } - else if (environment == Environment.NETHER) { + } else if (environment == Environment.NETHER) { return HeadTexture.GLOBE_NETHER.getAsItemStack(); - } - else if (environment == Environment.THE_END) { + } else if (environment == Environment.THE_END) { return HeadTexture.GLOBE_THE_END.getAsItemStack(); - } - else { + } else { return HeadTexture.GLOBE_OVERWORLD.getAsItemStack(); } } @@ -220,7 +216,8 @@ public class GPSNetwork { int index = 0; for (Waypoint waypoint : profile.getWaypoints()) { - if (index >= inventory.length) break; + if (index >= inventory.length) + break; int slot = inventory[index]; Location l = waypoint.getLocation(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java index 32c4d485a..e81bcf6a4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/gps/TeleportationManager.java @@ -92,7 +92,8 @@ public final class TeleportationManager { @ParametersAreNonnullByDefault public int getTeleportationTime(int complexity, Location source, Location destination) { - if (complexity < 100) return 100; + if (complexity < 100) + return 100; int speed = 50_000 + complexity * complexity; return 1 + Math.min(4 * distanceSquared(source, destination) / speed, 40); @@ -103,8 +104,7 @@ public final class TeleportationManager { if (source.getWorld().getUID().equals(destination.getWorld().getUID())) { int distance = (int) source.distanceSquared(destination); return Math.min(distance, 100_000_000); - } - else { + } else { return 150_000_000; } } @@ -129,8 +129,7 @@ public final class TeleportationManager { if (progress > 99) { p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20); PaperLib.teleportAsync(p, destination).thenAccept(success -> onTeleport(p, destination, success, resistance)); - } - else { + } else { p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0); source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F); @@ -138,8 +137,7 @@ public final class TeleportationManager { SlimefunPlugin.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L); } - } - else { + } else { cancel(uuid, p); } } @@ -161,8 +159,7 @@ public final class TeleportationManager { destination.getWorld().spawnParticle(Particle.PORTAL, loc, 200, 0.2F, 0.8F, 0.2F); destination.getWorld().playSound(destination, Sound.BLOCK_BEACON_ACTIVATE, 1F, 1F); teleporterUsers.remove(p.getUniqueId()); - } - else { + } else { // Make sure the Player is removed from the actively teleporting users // and notified about the failed teleportation cancel(p.getUniqueId(), p); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java index 826da2058..15b25a0bc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/HashedArmorpiece.java @@ -54,8 +54,7 @@ public final class HashedArmorpiece { public void update(@Nullable ItemStack stack, @Nullable SlimefunItem item) { if (stack == null || stack.getType() == Material.AIR) { this.hash = 0; - } - else { + } else { ItemStack copy = stack.clone(); ItemMeta meta = copy.getItemMeta(); ((Damageable) meta).setDamage(0); @@ -65,8 +64,7 @@ public final class HashedArmorpiece { if (item instanceof SlimefunArmorPiece) { this.item = Optional.of((SlimefunArmorPiece) item); - } - else { + } else { this.item = Optional.empty(); } } @@ -82,8 +80,7 @@ public final class HashedArmorpiece { public boolean hasDiverged(@Nullable ItemStack stack) { if (stack == null || stack.getType() == Material.AIR) { return hash != 0; - } - else { + } else { ItemStack copy = stack.clone(); ItemMeta meta = copy.getItemMeta(); ((Damageable) meta).setDamage(0); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java index ce98a6a35..7eedda655 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/items/ItemSetting.java @@ -69,8 +69,7 @@ public class ItemSetting { public void update(@Nonnull T newValue) { if (validateInput(newValue)) { this.value = newValue; - } - else { + } else { throw new IllegalArgumentException("The passed value was not valid. (Maybe null?)"); } @@ -134,8 +133,7 @@ public class ItemSetting { if (defaultValue.getClass().isInstance(configuredValue)) { this.value = (T) configuredValue; - } - else { + } else { this.value = defaultValue; String found = configuredValue == null ? "null" : configuredValue.getClass().getSimpleName(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java index bc974b25b..f058941b3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/network/Network.java @@ -122,8 +122,7 @@ public abstract class Network { public void markDirty(@Nonnull Location l) { if (regulator.equals(l)) { manager.unregisterNetwork(this); - } - else { + } else { nodeQueue.add(l.clone()); } } @@ -143,11 +142,9 @@ public abstract class Network { private NetworkComponent getCurrentClassification(@Nonnull Location l) { if (regulatorNodes.contains(l)) { return NetworkComponent.REGULATOR; - } - else if (connectorNodes.contains(l)) { + } else if (connectorNodes.contains(l)) { return NetworkComponent.CONNECTOR; - } - else if (terminusNodes.contains(l)) { + } else if (terminusNodes.contains(l)) { return NetworkComponent.TERMINUS; } @@ -168,20 +165,17 @@ public abstract class Network { // Requires a complete rebuild of the network, so we just throw the current one away. manager.unregisterNetwork(this); return; - } - else if (currentAssignment == NetworkComponent.TERMINUS) { + } else if (currentAssignment == NetworkComponent.TERMINUS) { terminusNodes.remove(l); } if (classification == NetworkComponent.REGULATOR) { regulatorNodes.add(l); discoverNeighbors(l); - } - else if (classification == NetworkComponent.CONNECTOR) { + } else if (classification == NetworkComponent.CONNECTOR) { connectorNodes.add(l); discoverNeighbors(l); - } - else if (classification == NetworkComponent.TERMINUS) { + } else if (classification == NetworkComponent.TERMINUS) { terminusNodes.add(l); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java index db3043ab1..e6d745773 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java @@ -95,8 +95,7 @@ public final class PlayerProfile { Location loc = waypointsFile.getLocation(key); 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() + '"'); } } @@ -182,8 +181,7 @@ public final class PlayerProfile { if (unlock) { configFile.setValue("researches." + research.getID(), true); researches.add(research); - } - else { + } else { configFile.setValue("researches." + research.getID(), null); researches.remove(research); } @@ -303,8 +301,7 @@ public final class PlayerProfile { if (backpack != null) { return Optional.of(backpack); - } - else if (configFile.contains("backpacks." + id + ".size")) { + } else if (configFile.contains("backpacks." + id + ".size")) { backpack = new PlayerBackpack(this, id); backpacks.put(id, backpack); return Optional.of(backpack); @@ -477,8 +474,7 @@ public final class PlayerProfile { if (!armorPiece.isPresent()) { setId = null; - } - else if (armorPiece.get() instanceof ProtectiveArmor) { + } else if (armorPiece.get() instanceof ProtectiveArmor) { ProtectiveArmor protectedArmor = (ProtectiveArmor) armorPiece.get(); if (setId == null && protectedArmor.isFullSetRequired()) { @@ -489,8 +485,7 @@ public final class PlayerProfile { if (protectionType == type) { if (setId == null) { return true; - } - else if (setId.equals(protectedArmor.getArmorSetId())) { + } else if (setId.equals(protectedArmor.getArmorSetId())) { armorCount++; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java index 36d3aeb71..c108221ce 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/StatusEffect.java @@ -100,13 +100,12 @@ public class StatusEffect implements Keyed { if (timestamp == 0 || timestamp >= System.currentTimeMillis()) { return true; - } - else { + } else { clear(p); return false; } - } - else return false; + } else + return false; } /** @@ -124,8 +123,8 @@ public class StatusEffect implements Keyed { String[] data = PatternUtils.SEMICOLON.split(optional.get()); return OptionalInt.of(Integer.parseInt(data[0])); - } - else return OptionalInt.empty(); + } else + return OptionalInt.empty(); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java index d4421b997..3cd3241d8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/DamageableItem.java @@ -59,8 +59,7 @@ public interface DamageableItem extends ItemAttribute { if (damageable.getDamage() >= item.getType().getMaxDurability()) { p.playSound(p.getEyeLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); item.setAmount(0); - } - else { + } else { damageable.setDamage(damageable.getDamage() + 1); item.setItemMeta(meta); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java index 91262da84..06123f1e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/EnergyNetComponent.java @@ -70,8 +70,7 @@ public interface EnergyNetComponent extends ItemAttribute { if (charge != null) { return Integer.parseInt(charge); - } - else { + } else { return 0; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java index 119b9f693..c408e6938 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/attributes/MachineType.java @@ -4,8 +4,8 @@ import javax.annotation.Nonnull; public enum MachineType { - CAPACITOR("Capacitor"), - GENERATOR("Generator"), + CAPACITOR("Capacitor"), + GENERATOR("Generator"), MACHINE("Machine"); private final String suffix; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java index dcbce8ff5..b061f475e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SlimefunTabCompleter.java @@ -33,12 +33,10 @@ class SlimefunTabCompleter implements TabCompleter { public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { if (args.length == 1) { return createReturnList(command.getSubCommandNames(), args[0]); - } - else if (args.length == 3) { + } else if (args.length == 3) { if (args[0].equalsIgnoreCase("give")) { return createReturnList(getSlimefunItems(), args[2]); - } - else if (args[0].equalsIgnoreCase("research")) { + } else if (args[0].equalsIgnoreCase("research")) { List researches = SlimefunPlugin.getRegistry().getResearches(); List suggestions = new LinkedList<>(); @@ -50,16 +48,13 @@ class SlimefunTabCompleter implements TabCompleter { } return createReturnList(suggestions, args[2]); - } - else { + } else { // Returning null will make it fallback to the default arguments (all online players) return null; } - } - else if (args.length == 4 && args[0].equalsIgnoreCase("give")) { + } else if (args.length == 4 && args[0].equalsIgnoreCase("give")) { return createReturnList(Arrays.asList("1", "2", "4", "8", "16", "32", "64"), args[3]); - } - else { + } else { // Returning null will make it fallback to the default arguments (all online players) return null; } @@ -90,8 +85,7 @@ class SlimefunTabCompleter implements TabCompleter { if (returnList.size() >= MAX_SUGGESTIONS) { break; } - } - else if (item.equalsIgnoreCase(input)) { + } else if (item.equalsIgnoreCase(input)) { return Collections.emptyList(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java index f3c2f044b..28b54fd18 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/SubCommand.java @@ -83,8 +83,7 @@ public abstract class SubCommand { public String getDescription(@Nonnull CommandSender sender) { if (sender instanceof Player) { return SlimefunPlugin.getLocalization().getMessage((Player) sender, getDescription()); - } - else { + } else { return SlimefunPlugin.getLocalization().getMessage(getDescription()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java index 20274c7e0..cdc65a340 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/BackpackCommand.java @@ -61,12 +61,10 @@ class BackpackCommand extends SubCommand { SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given"); }); }); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java index 3ea6b70e4..8d3a64f09 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ChargeCommand.java @@ -39,16 +39,13 @@ class ChargeCommand extends SubCommand { Rechargeable rechargeableItem = (Rechargeable) slimefunItem; rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item)); SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.charge-success", true); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java index 450abd94d..3a4e18aca 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/CheatCommand.java @@ -19,12 +19,10 @@ class CheatCommand extends SubCommand { if (sender instanceof Player) { if (sender.hasPermission("slimefun.cheat.items")) { SlimefunGuide.openCheatMenu((Player) sender); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java index f1e8656fc..1900a471d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/DebugFishCommand.java @@ -18,8 +18,7 @@ class DebugFishCommand extends SubCommand { public void onExecute(CommandSender sender, String[] args) { if (sender instanceof Player && sender.hasPermission("slimefun.debugging")) { ((Player) sender).getInventory().addItem(SlimefunItems.DEBUG_FISH.clone()); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java index 400ab5958..64c741ca1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GiveCommand.java @@ -39,20 +39,16 @@ class GiveCommand extends SubCommand { if (sfItem != null) { giveItem(sender, p, sfItem, args); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-valid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2])); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf give [Amount]")); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } } @@ -60,13 +56,12 @@ class GiveCommand extends SubCommand { private void giveItem(CommandSender sender, Player p, SlimefunItem sfItem, String[] args) { if (sfItem instanceof MultiBlockMachine) { SlimefunPlugin.getLocalization().sendMessage(sender, "guide.cheat.no-multiblocks"); - } - else { + } else { int amount = parseAmount(args); if (amount > 0) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); - Map excess = p.getInventory().addItem(new CustomItem(sfItem.getItem(), amount)); + Map excess = p.getInventory().addItem(new CustomItem(sfItem.getItem(), amount)); if (SlimefunPlugin.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) { for (ItemStack is : excess.values()) { p.getWorld().dropItem(p.getLocation(), is); @@ -74,8 +69,7 @@ class GiveCommand extends SubCommand { } SlimefunPlugin.getLocalization().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount))); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-valid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3])); } } @@ -87,8 +81,7 @@ class GiveCommand extends SubCommand { if (args.length == 4) { if (PatternUtils.NUMERIC.matcher(args[3]).matches()) { amount = Integer.parseInt(args[3]); - } - else { + } else { return 0; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java index 19b6b40a2..ce0c4ea94 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/GuideCommand.java @@ -21,12 +21,10 @@ class GuideCommand extends SubCommand { if (sender.hasPermission("slimefun.command.guide")) { SlimefunGuideLayout design = SlimefunGuide.getDefaultLayout(); ((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone()); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java index ab6e087b2..a4af9f2bd 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/OpenGuideCommand.java @@ -21,12 +21,10 @@ class OpenGuideCommand extends SubCommand { if (sender.hasPermission("slimefun.command.open_guide")) { boolean book = SlimefunPlugin.getCfg().getBoolean("guide.default-view-book"); SlimefunGuide.openGuide((Player) sender, book ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java index bb230acda..dacdb30e2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/ResearchCommand.java @@ -40,22 +40,18 @@ class ResearchCommand extends SubCommand { PlayerProfile.get(p, profile -> { if (args[2].equalsIgnoreCase("all")) { researchAll(sender, profile, p); - } - else if (args[2].equalsIgnoreCase("reset")) { + } else if (args[2].equalsIgnoreCase("reset")) { reset(profile, p); - } - else { + } else { giveResearch(sender, p, args[2]); } }); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1])); } - } - else SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); - } - else { + } else + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf research ")); } } @@ -68,8 +64,7 @@ class ResearchCommand extends SubCommand { UnaryOperator variables = msg -> msg.replace(PLACEHOLDER_PLAYER, player.getName()).replace(PLACEHOLDER_RESEARCH, research.get().getName(player)); SlimefunPlugin.getLocalization().sendMessage(player, "messages.give-research", true, variables); }); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-valid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java index 22169a7ae..af311645f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/SearchCommand.java @@ -24,16 +24,13 @@ class SearchCommand extends SubCommand { if (args.length > 1) { String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length)); PlayerProfile.get((Player) sender, profile -> SlimefunGuide.openSearch(profile, query, true, true)); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search ")); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java index a2e9628b3..11abe9817 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/StatsCommand.java @@ -26,17 +26,14 @@ class StatsCommand extends SubCommand { if (player.isPresent()) { PlayerProfile.get(player.get(), profile -> profile.sendStats(sender)); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1])); } - } - else SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); - } - else if (sender instanceof Player) { + } else + SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); + } else if (sender instanceof Player) { PlayerProfile.get((Player) sender, profile -> profile.sendStats(sender)); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java index 8031116ca..2d7d56ba5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TeleporterCommand.java @@ -23,28 +23,23 @@ class TeleporterCommand extends SubCommand { if (args.length == 1) { Player p = (Player) sender; SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI(p, p.getUniqueId(), p.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999); - } - else if (args.length == 2) { + } else if (args.length == 2) { @SuppressWarnings("deprecation") OfflinePlayer player = Bukkit.getOfflinePlayer(args[1]); if (player.getName() != null) { SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI((Player) sender, player.getUniqueId(), ((Player) sender).getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1])); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]")); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission"); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java index 7b5e4b7e9..5498a5e9d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/TimingsCommand.java @@ -18,8 +18,7 @@ class TimingsCommand extends SubCommand { if (sender.hasPermission("slimefun.command.timings") || sender instanceof ConsoleCommandSender) { sender.sendMessage("Please wait a second... The results are coming in!"); SlimefunPlugin.getProfiler().requestSummary(sender); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java index 505f29c62..0ede8e61f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/commands/subcommands/VersionsCommand.java @@ -51,13 +51,11 @@ class VersionsCommand extends SubCommand { if (Bukkit.getPluginManager().isPluginEnabled(plugin)) { sender.sendMessage(ChatColor.GREEN + " " + plugin.getName() + ChatColor.DARK_GREEN + " v" + version); - } - else { + } else { sender.sendMessage(ChatColor.RED + " " + plugin.getName() + ChatColor.DARK_RED + " v" + version); } } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java index a2c0b1ebc..7c1088ee8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/GuideHistory.java @@ -105,8 +105,7 @@ public class GuideHistory { if (lastEntry != null && lastEntry.getIndexedObject().equals(object)) { lastEntry.setPage(page); - } - else { + } else { queue.add(new GuideEntry<>(object, page)); } } @@ -167,20 +166,15 @@ public class GuideHistory { private void open(@Nonnull SlimefunGuideImplementation guide, @Nullable GuideEntry entry) { if (entry == null) { guide.openMainMenu(profile, 1); - } - else if (entry.getIndexedObject() instanceof Category) { + } else if (entry.getIndexedObject() instanceof Category) { guide.openCategory(profile, (Category) entry.getIndexedObject(), entry.getPage()); - } - else if (entry.getIndexedObject() instanceof SlimefunItem) { + } else if (entry.getIndexedObject() instanceof SlimefunItem) { guide.displayItem(profile, (SlimefunItem) entry.getIndexedObject(), false); - } - else if (entry.getIndexedObject() instanceof ItemStack) { + } else if (entry.getIndexedObject() instanceof ItemStack) { guide.displayItem(profile, (ItemStack) entry.getIndexedObject(), entry.getPage(), false); - } - else if (entry.getIndexedObject() instanceof String) { + } else if (entry.getIndexedObject() instanceof String) { guide.openSearch(profile, (String) entry.getIndexedObject(), false); - } - else { + } else { throw new IllegalStateException("Unknown GuideHistory entry: " + entry.getIndexedObject()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java index 290be0f44..0fd23d500 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuide.java @@ -41,14 +41,11 @@ public final class SlimefunGuide { public static void openGuide(Player p, ItemStack guide) { if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEST), true)) { openGuide(p, SlimefunGuideLayout.CHEST); - } - else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.BOOK), true)) { + } else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.BOOK), true)) { openGuide(p, SlimefunGuideLayout.BOOK); - } - else if (SlimefunUtils.isItemSimilar(guide, getItem(SlimefunGuideLayout.CHEAT_SHEET), true)) { + } 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); } @@ -65,8 +62,7 @@ public final class SlimefunGuide { PlayerProfile profile = optional.get(); SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getGuideLayout(layout); profile.getGuideHistory().openLastEntry(guide); - } - else { + } else { openMainMenuAsync(p, layout, 1); } } @@ -82,13 +78,15 @@ public final class SlimefunGuide { } public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideLayout layout, int selectedPage) { - if (category == null) return; + if (category == null) + return; SlimefunPlugin.getRegistry().getGuideLayout(layout).openCategory(profile, category, selectedPage); } public static void openSearch(PlayerProfile profile, String input, boolean survival, boolean addToHistory) { SlimefunGuideImplementation layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEST); - if (!survival) layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET); + if (!survival) + layout = SlimefunPlugin.getRegistry().getGuideLayout(SlimefunGuideLayout.CHEAT_SHEET); layout.openSearch(profile, input, addToHistory); } @@ -107,8 +105,7 @@ public final class SlimefunGuide { public static SlimefunGuideLayout getDefaultLayout() { if (SlimefunPlugin.getCfg().getBoolean("guide.default-view-book")) { return SlimefunGuideLayout.BOOK; - } - else { + } else { return SlimefunGuideLayout.CHEST; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java index 61f1a92f9..5ed728760 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/SlimefunGuideImplementation.java @@ -71,8 +71,7 @@ public interface SlimefunGuideImplementation { if (p.getGameMode() == GameMode.CREATIVE && SlimefunPlugin.getRegistry().isFreeCreativeResearchingEnabled()) { research.unlock(p, true, callback); - } - else { + } else { p.setLevel(p.getLevel() - research.getCost()); research.unlock(p, false, callback); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java index 9563e42f6..25465c92d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/FireworksOption.java @@ -30,8 +30,7 @@ class FireworksOption implements SlimefunGuideOption { boolean enabled = getSelectedOption(p, guide).orElse(true); ItemStack item = new CustomItem(Material.FIREWORK_ROCKET, "&bFireworks: &" + (enabled ? "aYes" : "4No"), "", "&7You can now toggle whether you", "&7will be presented with a big firework", "&7upon researching an item.", "", "&7\u21E8 &eClick to " + (enabled ? "disable" : "enable") + " your fireworks"); return Optional.of(item); - } - else { + } else { return Optional.empty(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java index f30704905..cf19b812d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/GuideLayoutOption.java @@ -40,11 +40,9 @@ class GuideLayoutOption implements SlimefunGuideOption { if (layout == SlimefunGuideLayout.CHEST) { item.setType(Material.CHEST); - } - else if (layout == SlimefunGuideLayout.BOOK) { + } else if (layout == SlimefunGuideLayout.BOOK) { item.setType(Material.BOOK); - } - else { + } else { item.setType(Material.COMMAND_BLOCK); } @@ -93,8 +91,7 @@ class GuideLayoutOption implements SlimefunGuideOption { } return SlimefunGuideLayout.CHEST; - } - else { + } else { return layout == SlimefunGuideLayout.CHEST ? SlimefunGuideLayout.BOOK : SlimefunGuideLayout.CHEST; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java index 229df7f5c..e435bfdf8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/PlayerLanguageOption.java @@ -50,8 +50,7 @@ class PlayerLanguageOption implements SlimefunGuideOption { ItemStack item = new CustomItem(language.getItem(), "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0])); return Optional.of(item); - } - else { + } else { return Optional.empty(); } } @@ -70,8 +69,7 @@ class PlayerLanguageOption implements SlimefunGuideOption { public void setSelectedOption(Player p, ItemStack guide, String value) { if (value == null) { PersistentDataAPI.remove(p, getKey()); - } - else { + } else { PersistentDataAPI.setString(p, getKey(), value); } } @@ -88,15 +86,13 @@ class PlayerLanguageOption implements SlimefunGuideOption { SlimefunGuideSettings.openSettings(pl, guide); return false; }); - } - else if (i == 7) { + } else if (i == 7) { menu.addItem(7, new CustomItem(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> { ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun"); pl.closeInventory(); return false; }); - } - else { + } else { menu.addItem(i, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java index dca978e1f..7c132d44f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/guide/options/SlimefunGuideSettings.java @@ -113,8 +113,7 @@ public final class SlimefunGuideSettings { ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/issues"); return false; }); - } - else { + } else { menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java index 8824d2a6e..54f4d6f74 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/multiblocks/MultiBlockMachine.java @@ -122,8 +122,7 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace } return true; - } - else { + } else { return false; } }; @@ -156,8 +155,7 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace // check for the dispenser, only refactored. if (outputInv == null && InvUtils.fits(placeCheckerInv, product)) { return dispInv; - } - else { + } else { return outputInv; } } @@ -195,11 +193,9 @@ public abstract class MultiBlockMachine extends SlimefunItem implements NotPlace for (ItemStack item : items) { if (item == null) { materials.add(null); - } - else if (item.getType() == Material.FLINT_AND_STEEL) { + } else if (item.getType() == Material.FLINT_AND_STEEL) { materials.add(Material.FIRE); - } - else { + } else { materials.add(item.getType()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java index 0b277ad30..f5592a493 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNet.java @@ -57,8 +57,7 @@ public class CargoNet extends ChestTerminalNetwork { if (cargoNetwork.isPresent()) { return cargoNetwork.get(); - } - else { + } else { CargoNet network = new CargoNet(l); SlimefunPlugin.getNetworkManager().registerNetwork(network); return network; @@ -152,8 +151,7 @@ public class CargoNet extends ChestTerminalNetwork { if (connectorNodes.isEmpty() && terminusNodes.isEmpty()) { SimpleHologram.update(b, "&cNo Cargo Nodes found"); - } - else { + } else { SimpleHologram.update(b, "&7Status: &a&lONLINE"); // Skip ticking if the threshold is not reached. The delay is not same as minecraft tick, @@ -192,8 +190,7 @@ public class CargoNet extends ChestTerminalNetwork { if (frequency == 16) { chestTerminalNodes.add(node); - } - else if (frequency >= 0 && frequency < 16) { + } else if (frequency >= 0 && frequency < 16) { inputs.put(node, frequency); } } @@ -252,8 +249,7 @@ public class CargoNet extends ChestTerminalNetwork { try { String str = BlockStorage.getLocationInfo(node).getString("frequency"); 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() + ")"); return 0; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java index 7ac5912ed..051b964d2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoNetworkTask.java @@ -111,25 +111,22 @@ class CargoNetworkTask implements Runnable { // Check if the original slot hasn't been occupied in the meantime if (inv.getItem(previousSlot) == null) { inv.setItem(previousSlot, stack); - } - else { + } else { // Try to add the item into another available slot then ItemStack rest = inv.addItem(stack).get(0); - + if (rest != null) { // If the item still couldn't be inserted, simply drop it on the ground inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), rest); } } - } - else { + } else { DirtyChestMenu menu = CargoUtils.getChestMenu(inputTarget); if (menu != null) { if (menu.getItemInSlot(previousSlot) == null) { menu.replaceExistingItem(previousSlot, stack); - } - else { + } else { inputTarget.getWorld().dropItem(inputTarget.getLocation().add(0, 1, 0), stack); } } @@ -183,8 +180,7 @@ class CargoNetworkTask implements Runnable { } index++; - } - else { + } else { index = 1; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java index e6eefd438..81c8051c2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/CargoUtils.java @@ -92,30 +92,24 @@ final class CargoUtils { if (isSmeltable(item, true)) { // Any non-smeltable items should not land in the upper slot return new int[] { 0, 2 }; - } - else { + } else { return new int[] { 1, 2 }; } - } - else { + } else { return new int[] { 0, 1 }; } - } - else if (inv instanceof BrewerInventory) { + } else if (inv instanceof BrewerInventory) { if (isPotion(item)) { // Slots for potions return new int[] { 0, 3 }; - } - else if (item != null && item.getType() == Material.BLAZE_POWDER) { + } else if (item != null && item.getType() == Material.BLAZE_POWDER) { // Blaze Powder slot return new int[] { 4, 5 }; - } - else { + } else { // Input slot return new int[] { 3, 4 }; } - } - else { + } else { // Slot 0-size return new int[] { 0, inv.getSize() }; } @@ -125,12 +119,10 @@ final class CargoUtils { if (inv instanceof FurnaceInventory) { // Slot 2-3 return new int[] { 2, 3 }; - } - else if (inv instanceof BrewerInventory) { + } else if (inv instanceof BrewerInventory) { // Slot 0-3 return new int[] { 0, 3 }; - } - else { + } else { // Slot 0-size return new int[] { 0, inv.getSize() }; } @@ -169,8 +161,7 @@ final class CargoUtils { is.setAmount(is.getAmount() - template.getAmount()); menu.replaceExistingItem(slot, is.clone()); return template; - } - else { + } else { menu.replaceExistingItem(slot, null); return is; } @@ -196,8 +187,7 @@ final class CargoUtils { if (itemInSlot.getAmount() > template.getAmount()) { itemInSlot.setAmount(itemInSlot.getAmount() - template.getAmount()); return template; - } - else { + } else { ItemStack clone = itemInSlot.clone(); itemInSlot.setAmount(0); return clone; @@ -220,8 +210,7 @@ final class CargoUtils { return new ItemStackAndInteger(is, slot); } } - } - else if (hasInventory(target)) { + } else if (hasInventory(target)) { Inventory inventory = inventories.get(target.getLocation()); if (inventory != null) { @@ -304,8 +293,7 @@ final class CargoUtils { itemInSlot.setAmount(Math.min(amount, maxStackSize)); if (amount > maxStackSize) { stack.setAmount(amount - maxStackSize); - } - else { + } else { stack = null; } @@ -332,8 +320,7 @@ final class CargoUtils { if (itemInSlot == null) { inv.setItem(slot, stack); return null; - } - else { + } else { int maxStackSize = itemInSlot.getType().getMaxStackSize(); if (SlimefunUtils.isItemSimilar(itemInSlot, wrapper, true, false) && itemInSlot.getAmount() < maxStackSize) { @@ -341,8 +328,7 @@ final class CargoUtils { if (amount > maxStackSize) { stack.setAmount(amount - maxStackSize); - } - else { + } else { stack = null; } @@ -372,8 +358,12 @@ final class CargoUtils { Config blockData = BlockStorage.getLocationInfo(block.getLocation()); String id = blockData.getString("id"); - // Cargo Output nodes have no filter actually - if (id.equals("CARGO_NODE_OUTPUT")) { + if (id == null) { + // This should normally not happen but if it does... + // Don't accept any items. + return false; + } else if (id.equals("CARGO_NODE_OUTPUT")) { + // Cargo Output nodes have no filter actually return true; } @@ -387,8 +377,7 @@ final class CargoUtils { boolean lore = "true".equals(blockData.getString("filter-lore")); boolean allowByDefault = !"whitelist".equals(blockData.getString("filter-type")); return matchesFilterList(item, menu, lore, allowByDefault); - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while trying to filter items for a Cargo Node (" + id + ") at " + new BlockPosition(block)); return false; } @@ -449,8 +438,7 @@ final class CargoUtils { private static boolean isSmeltable(@Nullable ItemStack stack, boolean lazy) { if (lazy) { return stack != null && Tag.LOGS.isTagged(stack.getType()); - } - else { + } else { return SlimefunPlugin.getMinecraftRecipeService().isSmeltable(stack); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java index 7ca0ccf21..4af214e38 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ChestTerminalNetwork.java @@ -164,15 +164,13 @@ abstract class ChestTerminalNetwork extends Network { if (is != null) { if (stack == null) { stack = is; - } - else { + } else { stack = new CustomItem(stack, stack.getAmount() + is.getAmount()); } if (is.getAmount() == item.getAmount()) { break; - } - else { + } else { item = new CustomItem(item, item.getAmount() - is.getAmount()); } } @@ -184,8 +182,7 @@ abstract class ChestTerminalNetwork extends Network { if (prev == null) { terminal.replaceExistingItem(slot, stack); - } - else { + } else { terminal.replaceExistingItem(slot, new CustomItem(stack, stack.getAmount() + prev.getAmount())); } } @@ -316,15 +313,13 @@ abstract class ChestTerminalNetwork extends Network { firstTerminal = l; } } - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { item.error("An Exception was caused while trying to tick Chest terminals", x); } if (firstTerminal != null) { return SlimefunPlugin.getProfiler().closeEntry(firstTerminal, item, timestamp); - } - else { + } else { return System.nanoTime() - timestamp; } } @@ -350,8 +345,7 @@ abstract class ChestTerminalNetwork extends Network { if (stack.getMaxStackSize() > 1) { int amount = item.getInt() > stack.getMaxStackSize() ? stack.getMaxStackSize() : item.getInt(); lore.add(ChatColors.color("&7")); - } - else { + } else { lore.add(ChatColors.color("&7")); } @@ -371,8 +365,7 @@ abstract class ChestTerminalNetwork extends Network { return false; }); - } - else { + } else { terminal.replaceExistingItem(slot, terminalPlaceholderItem); terminal.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler()); } @@ -403,18 +396,15 @@ abstract class ChestTerminalNetwork extends Network { ItemStack is = menu.getItemInSlot(slot); filter(is, items, l); } - } - else if (BlockStorage.hasInventory(target)) { + } else if (BlockStorage.hasInventory(target)) { BlockMenu blockMenu = BlockStorage.getInventory(target); if (blockMenu.getPreset().getID().startsWith("BARREL_")) { gatherItemsFromBarrel(l, blockMenu, items); - } - else { + } else { handleWithdraw(blockMenu, items, l); } - } - else if (CargoUtils.hasInventory(target)) { + } else if (CargoUtils.hasInventory(target)) { BlockState state = PaperLib.getBlockState(target, false).getState(); if (state instanceof InventoryHolder) { @@ -457,8 +447,7 @@ abstract class ChestTerminalNetwork extends Network { } } } - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, "An Exception occurred while trying to read data from a Barrel", x); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemRequest.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemRequest.java index a4779c1bf..2e015f5ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemRequest.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/cargo/ItemRequest.java @@ -47,8 +47,7 @@ class ItemRequest { if (obj instanceof ItemRequest) { ItemRequest request = (ItemRequest) obj; return Objects.equals(item, request.item) && Objects.equals(terminal, request.terminal) && slot == request.slot && flow == request.flow; - } - else { + } else { return false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java index 12127579b..c009dbab2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/networks/energy/EnergyNet.java @@ -68,8 +68,7 @@ public class EnergyNet extends Network { if (component == null) { return null; - } - else { + } else { switch (component.getEnergyComponentType()) { case CAPACITOR: return NetworkComponent.CONNECTOR; @@ -102,8 +101,7 @@ public class EnergyNet extends Network { case GENERATOR: if (component instanceof EnergyNetProvider) { generators.put(l, (EnergyNetProvider) component); - } - else if (component instanceof SlimefunItem) { + } else if (component instanceof SlimefunItem) { ((SlimefunItem) component).warn("This Item is marked as a GENERATOR but does not implement the interface EnergyNetProvider!"); } break; @@ -126,8 +124,7 @@ public class EnergyNet extends Network { if (connectorNodes.isEmpty() && terminusNodes.isEmpty()) { SimpleHologram.update(b, "&4No Energy Network found"); - } - else { + } else { int supply = tickAllGenerators(timestamp::getAndAdd) + tickAllCapacitors(); int remainingEnergy = supply; int demand = 0; @@ -146,8 +143,7 @@ public class EnergyNet extends Network { if (remainingEnergy > availableSpace) { component.setCharge(loc, capacity); remainingEnergy -= availableSpace; - } - else { + } else { component.setCharge(loc, charge + remainingEnergy); remainingEnergy = 0; } @@ -174,13 +170,11 @@ public class EnergyNet extends Network { if (remainingEnergy > capacity) { component.setCharge(loc, capacity); remainingEnergy -= capacity; - } - else { + } else { component.setCharge(loc, remainingEnergy); remainingEnergy = 0; } - } - else { + } else { component.setCharge(loc, 0); } } @@ -194,13 +188,11 @@ public class EnergyNet extends Network { if (remainingEnergy > capacity) { component.setCharge(loc, capacity); remainingEnergy -= capacity; - } - else { + } else { component.setCharge(loc, remainingEnergy); remainingEnergy = 0; } - } - else { + } else { component.setCharge(loc, 0); } } @@ -232,12 +224,10 @@ public class EnergyNet extends Network { loc.getBlock().setType(Material.LAVA); loc.getWorld().createExplosion(loc, 0F, false); }); - } - else { + } else { supply += energy; } - } - catch (Exception | LinkageError t) { + } catch (Exception | LinkageError t) { explodedBlocks.add(loc); new ErrorReport<>(t, loc, item); } @@ -265,8 +255,7 @@ public class EnergyNet extends Network { if (demand > supply) { String netLoss = DoubleHandler.getFancyDouble(Math.abs(supply - demand)); SimpleHologram.update(b, "&4&l- &c" + netLoss + " &7J &e\u26A1"); - } - else { + } else { String netGain = DoubleHandler.getFancyDouble(supply - demand); SimpleHologram.update(b, "&2&l+ &a" + netGain + " &7J &e\u26A1"); } @@ -298,8 +287,7 @@ public class EnergyNet extends Network { if (energyNetwork.isPresent()) { return energyNetwork.get(); - } - else { + } else { EnergyNet network = new EnergyNet(l); SlimefunPlugin.getNetworkManager().registerNetwork(network); return network; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java index 907a390ff..03784dd50 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/researching/Research.java @@ -244,8 +244,7 @@ public class Research implements Keyed { if (!event.isCancelled()) { if (instant) { finishResearch(p, profile, callback); - } - else if (SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) { + } else if (SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, getName(p))); playResearchAnimation(p); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java index 74f36a088..cb7a2bde1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BackupService.java @@ -42,8 +42,7 @@ public class BackupService implements Runnable { if (backups.size() > MAX_BACKUPS) { try { purgeBackups(backups); - } - catch (IOException e) { + } catch (IOException e) { Slimefun.getLogger().log(Level.WARNING, "Could not delete an old backup", e); } } @@ -58,12 +57,10 @@ public class BackupService implements Runnable { } Slimefun.getLogger().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()); } - } - catch (IOException x) { + } catch (IOException x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while creating a backup for Slimefun " + SlimefunPlugin.getVersion()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java index 5fcb9face..9dd1449f8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/BlockDataService.java @@ -65,8 +65,7 @@ public class BlockDataService implements PersistentDataService, Keyed { if (state instanceof TileState) { return getString((TileState) state, namespacedKey); - } - else { + } else { return Optional.empty(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java index a8fee3d63..d790144c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/LocalizationService.java @@ -72,16 +72,14 @@ public class LocalizationService extends SlimefunLocalization implements Persist if (hasLanguage(serverDefaultLanguage)) { setLanguage(serverDefaultLanguage, !serverDefaultLanguage.equals(language)); - } - else { + } else { setLanguage("en", false); 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())); save(); - } - else { + } else { translationsEnabled = false; defaultLanguage = null; } @@ -186,8 +184,7 @@ public class LocalizationService extends SlimefunLocalization implements Persist try (BufferedReader reader = new BufferedReader(new InputStreamReader(plugin.getClass().getResourceAsStream(path), StandardCharsets.UTF_8))) { FileConfiguration config = YamlConfiguration.loadConfiguration(reader); getConfig().getConfiguration().setDefaults(config); - } - catch (IOException e) { + } catch (IOException e) { Slimefun.getLogger().log(Level.SEVERE, e, () -> "Failed to load language file: \"" + path + "\""); } @@ -277,8 +274,7 @@ public class LocalizationService extends SlimefunLocalization implements Persist } return config; - } - catch (IOException e) { + } catch (IOException e) { Slimefun.getLogger().log(Level.SEVERE, e, () -> "Failed to load language file into memory: \"" + path + "\""); return null; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java index 14277f7c4..2da170c23 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MetricsService.java @@ -105,13 +105,11 @@ public class MetricsService { try { start.invoke(null); plugin.getLogger().info("Metrics build #" + version + " started."); - } - catch (Exception | LinkageError e) { + } catch (Exception | LinkageError e) { plugin.getLogger().log(Level.WARNING, "Failed to start metrics.", e); } }); - } - catch (Exception | LinkageError e) { + } catch (Exception | LinkageError e) { plugin.getLogger().log(Level.WARNING, "Failed to load the metrics module. Maybe the jar is corrupt?", e); } } @@ -125,8 +123,7 @@ public class MetricsService { if (moduleClassLoader != null) { moduleClassLoader.close(); } - } - catch (IOException e) { + } catch (IOException e) { plugin.getLogger().log(Level.WARNING, "Could not clean up module class loader. Some memory may have been leaked."); } } @@ -177,8 +174,7 @@ public class MetricsService { } return node.getObject().getInt("tag_name"); - } - catch (UnirestException e) { + } catch (UnirestException e) { plugin.getLogger().log(Level.WARNING, "Failed to fetch latest builds for Metrics: {0}", e.getMessage()); return -1; } @@ -224,11 +220,9 @@ public class MetricsService { hasDownloadedUpdate = true; return true; } - } - catch (UnirestException e) { + } catch (UnirestException e) { plugin.getLogger().log(Level.WARNING, "Failed to fetch the latest jar file from the builds page. Perhaps GitHub is down?"); - } - catch (IOException e) { + } catch (IOException e) { plugin.getLogger().log(Level.WARNING, "Failed to replace the old metric file with the new one. Please do this manually! Error: {0}", e.getMessage()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java index 7b3047ee1..9366dcb27 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/MinecraftRecipeService.java @@ -138,8 +138,7 @@ public class MinecraftRecipeService { } return choices.toArray(new RecipeChoice[0]); - } - else { + } else { return snapshot.getRecipeInput(recipe); } } @@ -156,8 +155,7 @@ public class MinecraftRecipeService { public Recipe[] getRecipesFor(@Nullable ItemStack item) { if (snapshot == null || item == null) { return new Recipe[0]; - } - else { + } else { return snapshot.getRecipesFor(item).toArray(new Recipe[0]); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java index f3c9ebf3f..9c76ef6c7 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PerWorldSettingsService.java @@ -106,8 +106,7 @@ public class PerWorldSettingsService { if (enabled) { items.remove(item.getID()); - } - else { + } else { items.add(item.getID()); } } @@ -126,8 +125,7 @@ public class PerWorldSettingsService { if (enabled) { disabledWorlds.remove(world.getUID()); - } - else { + } else { disabledWorlds.add(world.getUID()); } } @@ -196,8 +194,7 @@ public class PerWorldSettingsService { if (optional.isPresent()) { return optional.get(); - } - else { + } else { Set items = new LinkedHashSet<>(); Config config = getConfig(world); @@ -212,8 +209,7 @@ public class PerWorldSettingsService { if (SlimefunPlugin.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) { config.save(); } - } - else { + } else { disabledWorlds.add(world.getUID()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java index d3a1a7853..63b2fbe62 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/PermissionsService.java @@ -93,8 +93,7 @@ public class PermissionsService { if (permission == null || permission.equals("none")) { return Optional.empty(); - } - else { + } else { return Optional.of(permission); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java index f6512642e..46c409fa5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/UpdaterService.java @@ -46,31 +46,26 @@ public class UpdaterService { if (version.contains("UNOFFICIAL")) { // This Server is using a modified build that is not a public release. branch = SlimefunBranch.UNOFFICIAL; - } - else if (version.startsWith("DEV - ")) { + } else if (version.startsWith("DEV - ")) { // If we are using a development build, we want to switch to our custom try { autoUpdater = new GitHubBuildsUpdater(plugin, file, "TheBusyBiscuit/Slimefun4/master"); - } - catch (Exception x) { + } catch (Exception x) { plugin.getLogger().log(Level.SEVERE, "Failed to create AutoUpdater", x); } branch = SlimefunBranch.DEVELOPMENT; - } - else if (version.startsWith("RC - ")) { + } else if (version.startsWith("RC - ")) { // If we are using a "stable" build, we want to switch to our custom try { autoUpdater = new GitHubBuildsUpdater(plugin, file, "TheBusyBiscuit/Slimefun4/stable", "RC - "); - } - catch (Exception x) { + } catch (Exception x) { plugin.getLogger().log(Level.SEVERE, "Failed to create AutoUpdater", x); } branch = SlimefunBranch.STABLE; - } - else { + } else { branch = SlimefunBranch.UNKNOWN; } @@ -111,8 +106,7 @@ public class UpdaterService { public void start() { if (updater != null) { updater.start(); - } - else { + } else { printBorder(); plugin.getLogger().log(Level.WARNING, "It looks like you are using an unofficially modified build of Slimefun!"); plugin.getLogger().log(Level.WARNING, "Auto-Updates have been disabled, this build is not considered safe."); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java index 1d3f43e80..f38e0c035 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/ContributionsConnector.java @@ -66,8 +66,7 @@ class ContributionsConnector extends GitHubConnector { if (response.isArray()) { computeContributors(response.getArray()); - } - else { + } else { Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java index 82264255c..d558502ad 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/Contributor.java @@ -176,12 +176,10 @@ public class Contributor { if (github != null) { String cached = github.getCachedTexture(githubUsername); return cached != null ? cached : HeadTexture.UNKNOWN.getTexture(); - } - else { + } else { return HeadTexture.UNKNOWN.getTexture(); } - } - else { + } else { return headTexture.get(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java index 46913f44e..baa099769 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubConnector.java @@ -78,8 +78,7 @@ abstract class GitHubConnector { if (resp.isSuccess()) { onSuccess(resp.getBody()); writeCacheFile(resp.getBody()); - } - else { + } else { if (github.isLoggingEnabled()) { Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { repository + getURLSuffix(), resp.getStatus(), resp.getBody() }); } @@ -93,8 +92,7 @@ abstract class GitHubConnector { } } } - } - catch (UnirestException e) { + } catch (UnirestException e) { if (github.isLoggingEnabled()) { Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time."); } @@ -118,8 +116,7 @@ abstract class GitHubConnector { private JsonNode readCacheFile() { try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8))) { return new JsonNode(reader.readLine()); - } - catch (IOException | JSONException e) { + } 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() }); return null; } @@ -128,8 +125,7 @@ abstract class GitHubConnector { private void writeCacheFile(@Nonnull JsonNode node) { try (FileOutputStream output = new FileOutputStream(file)) { 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() }); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java index e30a6a623..b22d9f491 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubIssuesConnector.java @@ -33,15 +33,13 @@ class GitHubIssuesConnector extends GitHubConnector { if (obj.has("pull_request")) { pullRequests++; - } - else { + } else { issues++; } } callback.accept(issues, pullRequests); - } - else { + } else { Slimefun.getLogger().log(Level.WARNING, "Received an unusual answer from GitHub, possibly a timeout? ({0})", response); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java index 16e65d8f9..5401465fb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/github/GitHubTask.java @@ -78,17 +78,14 @@ class GitHubTask implements Runnable { try { if (skins.containsKey(contributor.getMinecraftName())) { contributor.setTexture(skins.get(contributor.getMinecraftName())); - } - else { + } else { contributor.setTexture(pullTexture(contributor, skins)); return contributor.getUniqueId().isPresent() ? 1 : 2; } - } - catch (IllegalArgumentException x) { + } catch (IllegalArgumentException x) { // There cannot be a texture found because it is not a valid MC username contributor.setTexture(null); - } - catch (IOException x) { + } catch (IOException x) { // 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() }); Slimefun.getLogger().log(Level.WARNING, "This usually means mojang.com is down or started to rate-limit this connection, this is not an error message!"); @@ -99,8 +96,7 @@ class GitHubTask implements Runnable { } return -1; - } - catch (TooManyRequestsException x) { + } catch (TooManyRequestsException x) { Slimefun.getLogger().log(Level.WARNING, "Received a rate-limit from mojang.com, retrying in 4 minutes"); Bukkit.getScheduler().runTaskLaterAsynchronously(SlimefunPlugin.instance(), this::grabTextures, 4 * 60 * 20L); @@ -124,8 +120,7 @@ class GitHubTask implements Runnable { Optional skin = MinecraftAccount.getSkin(uuid.get()); skins.put(contributor.getMinecraftName(), skin.orElse("")); return skin.orElse(null); - } - else { + } else { return null; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java index d7a937ba4..533b184ec 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/Language.java @@ -75,8 +75,7 @@ public final class Language { public double getTranslationProgress() { if (id.equals("en")) { return 100.0; - } - else { + } else { if (progress < 0) { progress = SlimefunPlugin.getLocalization().calculateProgress(this); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java index a4e21ba01..390f3a469 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/localization/SlimefunLocalization.java @@ -160,8 +160,7 @@ public abstract class SlimefunLocalization extends Localization implements Keyed if (value != null) { return value; - } - else { + } else { Language fallback = getLanguage(SupportedLanguage.ENGLISH.getLanguageId()); return fallback.getResourcesFile().getString(key); } @@ -199,8 +198,7 @@ public abstract class SlimefunLocalization extends Localization implements Keyed if (sender instanceof Player) { sender.sendMessage(ChatColors.color(prefix + getMessage((Player) sender, key))); - } - else { + } else { sender.sendMessage(ChatColor.stripColor(ChatColors.color(prefix + getMessage(key)))); } } @@ -224,8 +222,7 @@ public abstract class SlimefunLocalization extends Localization implements Keyed if (sender instanceof Player) { sender.sendMessage(ChatColors.color(prefix + function.apply(getMessage((Player) sender, key)))); - } - else { + } else { sender.sendMessage(ChatColor.stripColor(ChatColors.color(prefix + function.apply(getMessage(key))))); } } @@ -239,8 +236,7 @@ public abstract class SlimefunLocalization extends Localization implements Keyed String message = ChatColors.color(prefix + translation); sender.sendMessage(message); } - } - else { + } else { for (String translation : getMessages(key)) { String message = ChatColors.color(prefix + translation); sender.sendMessage(ChatColor.stripColor(message)); @@ -257,8 +253,7 @@ public abstract class SlimefunLocalization extends Localization implements Keyed String message = ChatColors.color(prefix + function.apply(translation)); sender.sendMessage(message); } - } - else { + } else { for (String translation : getMessages(key)) { String message = ChatColors.color(prefix + function.apply(translation)); sender.sendMessage(ChatColor.stripColor(message)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java index c0a40bf01..892729663 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/PlaceholderAPIHook.java @@ -56,8 +56,7 @@ class PlaceholderAPIHook extends PlaceholderExpansion { private boolean isPlaceholder(@Nullable OfflinePlayer p, boolean requiresProfile, @Nonnull String params, @Nonnull String placeholder) { if (requiresProfile) { return p != null && placeholder.equals(params) && PlayerProfile.request(p); - } - else { + } else { return placeholder.equals(params); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java index e90f0b0fa..877aac6b1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/ThirdPartyPluginService.java @@ -50,8 +50,7 @@ public class ThirdPartyPluginService { PlaceholderAPIHook hook = new PlaceholderAPIHook(plugin); hook.register(); isPlaceholderAPIInstalled = true; - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { String version = plugin.getServer().getPluginManager().getPlugin("PlaceholderAPI").getDescription().getVersion(); Slimefun.getLogger().log(Level.WARNING, "Maybe consider updating PlaceholderAPI or Slimefun?"); @@ -71,8 +70,7 @@ public class ThirdPartyPluginService { try { Class.forName("com.sk89q.worldedit.extent.Extent"); new WorldEditHook(); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { String version = plugin.getServer().getPluginManager().getPlugin("WorldEdit").getDescription().getVersion(); Slimefun.getLogger().log(Level.WARNING, "Maybe consider updating WorldEdit or Slimefun?"); @@ -98,8 +96,7 @@ public class ThirdPartyPluginService { if (plugin.getServer().getPluginManager().isPluginEnabled(hook)) { Slimefun.getLogger().log(Level.INFO, "Hooked into Plugin: {0}", hook); return true; - } - else { + } else { return false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java index f90f0663b..3b134df92 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/plugins/WorldEditHook.java @@ -37,7 +37,7 @@ class WorldEditHook { } } } - + return getExtent().setBlock(pos, block); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java index d46e5752a..4b46d9352 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/PerformanceSummary.java @@ -70,8 +70,7 @@ class PerformanceSummary { String average = NumberUtils.getAsMillis(entry.getValue() / count); return entry.getKey() + " - " + count + "x (" + time + " | avg: " + average + ')'; - } - else { + } else { return entry.getKey() + " - " + count + "x (" + time + ')'; } }); @@ -100,8 +99,7 @@ class PerformanceSummary { if (sender instanceof Player) { TextComponent component = summarizeAsTextComponent(count, prefix, results, formatter); sender.spigot().sendMessage(component); - } - else { + } else { String text = summarizeAsString(count, prefix, results, formatter); sender.sendMessage(text); } @@ -125,8 +123,7 @@ class PerformanceSummary { if (shownEntries < MAX_ITEMS && (shownEntries < MIN_ITEMS || entry.getValue() > VISIBILITY_THRESHOLD)) { builder.append("\n").append(ChatColor.YELLOW).append(formatter.apply(entry)); shownEntries++; - } - else { + } else { hiddenEntries++; } } @@ -161,8 +158,7 @@ class PerformanceSummary { builder.append("\n "); builder.append(ChatColor.stripColor(formatter.apply(entry))); shownEntries++; - } - else { + } else { hiddenEntries++; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java index b69118d89..d123c37c4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/core/services/profiler/SlimefunProfiler.java @@ -164,8 +164,7 @@ public class SlimefunProfiler { } return; } - } - catch (InterruptedException e) { + } catch (InterruptedException e) { Slimefun.getLogger().log(Level.SEVERE, "A Profiler Thread was interrupted", e); Thread.currentThread().interrupt(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java index e4c00f8cf..a0ee6597a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunItems.java @@ -681,7 +681,6 @@ public final class SlimefunItems { public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aCarbonado Edged Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &765536 J Capacity"); public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aEnergized Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7524288 J Capacity"); - /* Robots */ public static final SlimefunItemStack PROGRAMMABLE_ANDROID = new SlimefunItemStack("PROGRAMMABLE_ANDROID", HeadTexture.PROGRAMMABLE_ANDROID, "&cProgrammable Android &7(Normal)", "", "&8\u21E8 &7Function: None", "&8\u21E8 &7Fuel Efficiency: 1.0x"); public static final SlimefunItemStack PROGRAMMABLE_ANDROID_FARMER = new SlimefunItemStack("PROGRAMMABLE_ANDROID_FARMER", HeadTexture.PROGRAMMABLE_ANDROID_FARMER, "&cProgrammable Android &7(Farmer)", "", "&8\u21E8 &7Function: Farming", "&8\u21E8 &7Fuel Efficiency: 1.0x"); @@ -849,8 +848,7 @@ public final class SlimefunItems { MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.BLAST_FURNACE, "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots"); AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.SMOKER, "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10)); AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", Material.SMOKER, "&6Auto Brewer", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12)); - } - else { + } else { TABLE_SAW = null; MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.FURNACE, "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots"); AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.FURNACE, "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java index 0a237ef2a..ffab307ba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/SlimefunPlugin.java @@ -63,10 +63,10 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockListener import io.github.thebusybiscuit.slimefun4.implementation.listeners.BlockPhysicsListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CargoNodeListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.CoolerListener; -import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DeathpointListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DebugFishListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.DispenserListener; +import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.EnhancedFurnaceListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.EntityInteractionListener; import io.github.thebusybiscuit.slimefun4.implementation.listeners.ExplosionsListener; @@ -173,8 +173,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { networkManager = new NetworkManager(200); command.register(); registry.load(config); - } - else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) { + } else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) { long timestamp = System.nanoTime(); PaperLib.suggestPaper(this); @@ -221,8 +220,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { if (config.getBoolean("options.auto-update")) { getLogger().log(Level.INFO, "Starting Auto-Updater..."); updaterService.start(); - } - else { + } else { updaterService.disable(); } @@ -251,8 +249,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { // This try/catch should prevent buggy Spigot builds from blocking item loading try { recipeService.refresh(); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while iterating through the Recipe list on Minecraft Version " + minecraftVersion.getName() + " (Slimefun v" + getVersion() + ")"); } @@ -274,8 +271,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { // Hooray! getLogger().log(Level.INFO, "Slimefun has finished loading in {0}", getStartupTime(timestamp)); - } - else { + } else { instance = null; getLogger().log(Level.INFO, "#################### - INFO - ####################"); @@ -299,8 +295,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { if (ms > 1000) { return DoubleHandler.fixDouble(ms / 1000.0) + "s"; - } - else { + } else { return DoubleHandler.fixDouble(ms) + "ms"; } } @@ -376,8 +371,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { for (Map.Entry entry : getRegistry().getWorlds().entrySet()) { try { entry.getValue().saveAndRemove(); - } - catch (Exception x) { + } catch (Exception x) { getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving Slimefun-Blocks in World '" + entry.getKey() + "' for Slimefun " + getVersion()); } } @@ -498,8 +492,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { private void loadItems() { try { SlimefunItemSetup.setup(this); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing SlimefunItems for Slimefun " + getVersion()); } } @@ -507,8 +500,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon { private void loadResearches() { try { ResearchSetup.setupResearches(); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { getLogger().log(Level.SEVERE, x, () -> "An Error occurred while initializing Slimefun Researches for Slimefun " + getVersion()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java index d15c1936e..0a26c0a7f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/BookSlimefunGuide.java @@ -157,8 +157,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { ChatComponent chatComponent = new ChatComponent(ChatUtils.crop(ChatColor.RED, ItemUtils.getItemName(category.getItem(p))) + "\n"); chatComponent.setHoverEvent(new HoverEvent(lore)); lines.add(chatComponent); - } - else { + } 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))); @@ -176,8 +175,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { if (category instanceof FlexCategory) { ((FlexCategory) category).open(p, profile, getLayout()); - } - else if (category.getItems().size() < 250) { + } else if (category.getItems().size() < 250) { profile.getGuideHistory().add(category, page); List items = new LinkedList<>(); @@ -187,8 +185,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { if (Slimefun.isEnabled(p, slimefunItem, false)) { addSlimefunItem(category, page, p, profile, slimefunItem, items); } - } - else { + } else { ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.DARK_RED, ItemUtils.getItemName(slimefunItem.getItem())) + "\n"); List lore = new ArrayList<>(); @@ -205,8 +202,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { } openBook(p, profile, items, true); - } - else { + } else { p.sendMessage(ChatColor.RED + "That Category is too big to open :/"); } } @@ -222,8 +218,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { component.setClickEvent(new ClickEvent(key, player -> research(player, profile, item, research, category, page))); items.add(component); - } - else { + } else { ChatComponent component = new ChatComponent(ChatUtils.crop(ChatColor.DARK_GREEN, item.getItemName()) + "\n"); List lore = new ArrayList<>(); @@ -245,12 +240,10 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation { if (research.canUnlock(p)) { if (profile.hasUnlocked(research)) { openCategory(profile, category, page); - } - else { + } else { unlockItem(p, item, pl -> openCategory(profile, category, page)); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.not-enough-xp", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java index 4aacf3a40..5ca33706b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/ChestSlimefunGuide.java @@ -77,8 +77,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { sound = Sound.ITEM_BOOK_PAGE_TURN; - } - else { + } else { sound = Sound.ENTITY_BAT_TAKEOFF; } } @@ -184,8 +183,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { openCategory(profile, category, 1); return false; }); - } - else { + } else { List lore = new ArrayList<>(); lore.add(""); @@ -235,14 +233,16 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages)); menu.addMenuClickHandler(46, (pl, slot, item, action) -> { int next = page - 1; - if (next != page && next > 0) openCategory(profile, category, next); + if (next != page && next > 0) + openCategory(profile, category, next); return false; }); menu.addItem(52, ChestMenuUtils.getNextButton(p, page, pages)); menu.addMenuClickHandler(52, (pl, slot, item, action) -> { int next = page + 1; - if (next != page && next <= pages) openCategory(profile, category, next); + if (next != page && next <= pages) + openCategory(profile, category, next); return false; }); @@ -274,44 +274,37 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { List message = SlimefunPlugin.getPermissionsService().getLore(sfitem); menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[0]))); menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler()); - } - else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { + } else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) { menu.addItem(index, new CustomItem(Material.BARRIER, ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)")); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) { if (research.canUnlock(pl)) { if (profile.hasUnlocked(research)) { openCategory(profile, category, page); - } - else { + } else { unlockItem(pl, sfitem, player -> openCategory(profile, category, page)); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(pl, "messages.not-enough-xp", true); } } return false; }); - } - else { + } else { menu.addItem(index, sfitem.getItem()); menu.addMenuClickHandler(index, (pl, slot, item, action) -> { try { if (isSurvivalMode()) { displayItem(profile, sfitem, true); - } - else { + } else { if (sfitem instanceof MultiBlockMachine) { SlimefunPlugin.getLocalization().sendMessage(pl, "guide.cheat.no-multiblocks"); - } - else { + } else { pl.getInventory().addItem(sfitem.getItem().clone()); } } - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { printErrorMessage(pl, x); } @@ -370,12 +363,10 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { try { if (!isSurvivalMode()) { pl.getInventory().addItem(slimefunItem.getItem().clone()); - } - else { + } else { displayItem(profile, slimefunItem, true); } - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { printErrorMessage(pl, x); } @@ -432,8 +423,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { recipeType = new RecipeType(optional.get()); result = recipe.getResult(); - } - else { + } else { recipeItems = new ItemStack[] { null, null, null, null, new CustomItem(Material.BARRIER, "&4We are somehow unable to show you this Recipe :/"), null, null, null, null }; } @@ -481,8 +471,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { if (((MaterialChoice) choices[0]).getChoices().size() > 1) { task.add(recipeSlots[4], (MaterialChoice) choices[0]); } - } - else { + } else { for (int i = 0; i < choices.length; i++) { if (choices[i] instanceof MaterialChoice) { recipeItems[i] = new ItemStack(((MaterialChoice) choices[i]).getChoices().get(0)); @@ -546,8 +535,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { if (itemstack != null && itemstack.getType() != Material.BARRIER) { displayItem(profile, itemstack, 0, true); } - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { printErrorMessage(pl, x); } return false; @@ -610,15 +598,13 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { menu.addMenuClickHandler(slot, (pl, s, is, action) -> { if (action.isShiftClicked()) { openMainMenu(profile, 1); - } - else { + } else { history.goBack(this); } return false; }); - } - else { + } else { menu.addItem(slot, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide")))); menu.addMenuClickHandler(slot, (pl, s, is, action) -> { openMainMenu(profile, 1); @@ -637,8 +623,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { String lore = Slimefun.hasPermission(p, slimefunItem, false) ? "&fNeeds to be unlocked elsewhere" : "&fNo Permission"; return Slimefun.hasUnlocked(p, slimefunItem, false) ? item : new CustomItem(Material.BARRIER, ItemUtils.getItemName(item), "&4&l" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", lore); - } - else { + } else { return item; } } @@ -687,8 +672,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { if (i % 2 == 0) { slot = inputs; inputs++; - } - else { + } else { slot = outputs; outputs++; } @@ -716,8 +700,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation { return false; }); } - } - else { + } else { menu.replaceExistingItem(slot, null); menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java index ba43a78a1..62a0d6318 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/altar/AncientPedestal.java @@ -81,8 +81,7 @@ public class AncientPedestal extends SlimefunItem { ItemMeta meta = item.getItemStack().getItemMeta(); return meta.hasDisplayName() && meta.getDisplayName().startsWith(ITEM_PREFIX); - } - else { + } else { return false; } } @@ -95,8 +94,7 @@ public class AncientPedestal extends SlimefunItem { ItemMeta im = stack.getItemMeta(); im.setDisplayName(null); stack.setItemMeta(im); - } - else { + } else { ItemMeta im = stack.getItemMeta(); if (!customName.startsWith(String.valueOf(ChatColor.COLOR_CHAR))) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java index 48b90420b..f082b68f5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/MinerAndroid.java @@ -96,12 +96,10 @@ public class MinerAndroid extends ProgrammableAndroid { block.setType(Material.AIR); move(b, face, block); } - } - else { + } else { move(b, face, block); } - } - else { + } else { move(b, face, block); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java index 52fb2feb4..be15a49e3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/ProgrammableAndroid.java @@ -256,8 +256,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, BlockStorage.getInventory(b).open(pl); return false; }); - } - else { + } else { Instruction instruction = Instruction.getFromCache(script[i]); if (instruction == null) { @@ -276,13 +275,11 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, String code = duplicateInstruction(script, index); setScript(b.getLocation(), code); openScript(pl, b, code); - } - else if (action.isRightClicked()) { + } else if (action.isRightClicked()) { String code = deleteInstruction(script, index); setScript(b.getLocation(), code); openScript(pl, b, code); - } - else { + } else { editInstruction(pl, b, script, index); } @@ -303,8 +300,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, if (i > 0) { if (i == index) { builder.append(instruction).append('-'); - } - else if (i < script.length - 1) { + } else if (i < script.length - 1) { builder.append(current).append('-'); } } @@ -323,8 +319,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, if (i > 0) { if (i == index) { builder.append(script[i]).append('-').append(script[i]).append('-'); - } - else if (i < script.length - 1) { + } else if (i < script.length - 1) { builder.append(instruction).append('-'); } } @@ -409,23 +404,19 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, if (target >= scripts.size()) { break; - } - else { + } else { Script script = scripts.get(target); menu.addItem(index, script.getAsItemStack(this, p), (player, slot, stack, action) -> { if (action.isShiftClicked()) { if (script.isAuthor(player)) { SlimefunPlugin.getLocalization().sendMessage(player, "android.scripts.rating.own", true); - } - else if (script.canRate(player)) { + } else if (script.canRate(player)) { script.rate(player, !action.isRightClicked()); openScriptDownloader(player, b, page); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(player, "android.scripts.rating.already", true); } - } - else if (!action.isRightClicked()) { + } else if (!action.isRightClicked()) { script.download(); setScript(b.getLocation(), script.getSourceCode()); openScriptEditor(player, b); @@ -643,8 +634,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, if (fuel < 0.001) { consumeFuel(b, menu); - } - else { + } else { String code = data.getString("script"); String[] script = PatternUtils.DASH.split(code == null ? DEFAULT_SCRIPT : code); @@ -703,8 +693,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, if (index == POSSIBLE_ROTATIONS.size()) { index = 0; - } - else if (index < 0) { + } else if (index < 0) { index = POSSIBLE_ROTATIONS.size() - 1; } @@ -736,8 +725,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, if (optional.isPresent()) { menu.replaceExistingItem(slot, optional.get()); - } - else { + } else { menu.replaceExistingItem(slot, null); } } @@ -769,8 +757,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock, menu.replaceExistingItem(43, newFuel); dispenser.setItem(slot, null); return true; - } - else if (SlimefunUtils.isItemSimilar(newFuel, currentFuel, true, false)) { + } else if (SlimefunUtils.isItemSimilar(newFuel, currentFuel, true, false)) { int rest = newFuel.getType().getMaxStackSize() - currentFuel.getAmount(); if (rest > 0) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java index 783cff824..2b623dbc5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/Script.java @@ -221,8 +221,7 @@ public final class Script { if (config.contains("code") && config.contains("author")) { 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() + "'"); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java index 39cfa1ff0..2d79132b2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/androids/WoodcutterAndroid.java @@ -70,8 +70,7 @@ public class WoodcutterAndroid extends ProgrammableAndroid { Optional sapling = MaterialConverter.getSaplingFromLog(log.getType()); sapling.ifPresent(log::setType); - } - else { + } else { log.setType(Material.AIR); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java index cdeef8ca3..384289e8e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/ElytraCap.java @@ -1,5 +1,13 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.armor; +import javax.annotation.Nonnull; +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.GameMode; +import org.bukkit.NamespacedKey; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; + import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; @@ -8,11 +16,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.ElytraCrashLi import me.mrCookieSlime.Slimefun.Lists.RecipeType; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; -import org.bukkit.NamespacedKey; -import org.bukkit.inventory.ItemStack; - -import javax.annotation.Nonnull; -import javax.annotation.ParametersAreNonnullByDefault; /** * The {@link ElytraCap} negates damage taken when crashing into a wall using an elytra. @@ -37,10 +40,17 @@ public class ElytraCap extends SlimefunArmorPiece implements DamageableItem, Pro return true; } + @Override + public void damageItem(Player p, ItemStack item) { + if (p.getGameMode() != GameMode.CREATIVE) { + DamageableItem.super.damageItem(p, item); + } + } + @Nonnull @Override public ProtectionType[] getProtectionTypes() { - return new ProtectionType[] {ProtectionType.FLYING_INTO_WALL}; + return new ProtectionType[] { ProtectionType.FLYING_INTO_WALL }; } @Override diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java index 3ac3670a3..ca23601bc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/armor/StomperBoots.java @@ -83,8 +83,7 @@ public class StomperBoots extends SlimefunItem { // As the distance approaches zero we might slip into a "division by zero" when normalizing if (origin.distanceSquared(target) < 0.05) { return new Vector(0, 1, 0); - } - else { + } else { Vector direction = target.toVector().subtract(origin.toVector()); return direction.normalize().multiply(1.4); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java index d71d43ed8..40d0cb41f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/BlockPlacer.java @@ -91,8 +91,7 @@ public class BlockPlacer extends SlimefunItem { if (!(item instanceof NotPlaceable)) { placeSlimefunBlock(item, e.getItem(), facedBlock, dispenser); } - } - else { + } else { placeBlock(e.getItem(), facedBlock, dispenser); } } @@ -153,8 +152,7 @@ public class BlockPlacer extends SlimefunItem { if (dispenser.getInventory().containsAtLeast(item, 2)) { dispenser.getInventory().removeItem(new CustomItem(item, 1)); - } - else { + } else { SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } @@ -168,8 +166,7 @@ public class BlockPlacer extends SlimefunItem { if (dispenser.getInventory().containsAtLeast(item, 2)) { dispenser.getInventory().removeItem(new CustomItem(item, 1)); - } - else { + } else { SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } @@ -206,8 +203,7 @@ public class BlockPlacer extends SlimefunItem { if (dispenser.getInventory().containsAtLeast(item, 2)) { dispenser.getInventory().removeItem(new CustomItem(item, 1)); - } - else { + } else { SlimefunPlugin.runSync(() -> dispenser.getInventory().removeItem(item), 2L); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java index dfe498fca..a884c8733 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Composter.java @@ -101,8 +101,7 @@ public class Composter extends SimpleSlimefunItem implements Re }); tasks.execute(SlimefunPlugin.instance()); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); } } @@ -115,8 +114,7 @@ public class Composter extends SimpleSlimefunItem implements Re if (outputChest.isPresent()) { outputChest.get().addItem(output); - } - else { + } else { Location loc = b.getRelative(BlockFace.UP).getLocation(); b.getWorld().dropItemNaturally(loc, output); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java index 4ed2e7e3d..113cb76eb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/Crucible.java @@ -93,8 +93,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec if (craft(p, input)) { boolean water = Tag.LEAVES.isTagged(input.getType()); generateLiquid(block, water); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); } } @@ -122,13 +121,11 @@ public class Crucible extends SimpleSlimefunItem implements Rec private void generateLiquid(@Nonnull Block block, boolean water) { if (block.getType() == (water ? Material.WATER : Material.LAVA)) { addLiquidLevel(block, water); - } - else if (block.getType() == (water ? Material.LAVA : Material.WATER)) { + } else if (block.getType() == (water ? Material.LAVA : Material.WATER)) { int level = ((Levelled) block.getBlockData()).getLevel(); block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE); block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F); - } - else { + } else { SlimefunPlugin.runSync(() -> placeLiquid(block, water), 50L); } } @@ -142,8 +139,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec if (level == 0) { block.getWorld().playSound(block.getLocation(), water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, 1F, 1F); - } - else { + } else { int finalLevel = 7 - level; SlimefunPlugin.runSync(() -> runPostTask(block, water ? Sound.ENTITY_PLAYER_SPLASH : Sound.BLOCK_LAVA_POP, finalLevel), 50L); } @@ -152,8 +148,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec private void placeLiquid(@Nonnull Block block, boolean water) { if (block.getType() == Material.AIR || block.getType() == Material.CAVE_AIR || block.getType() == Material.VOID_AIR) { block.setType(water ? Material.WATER : Material.LAVA); - } - else { + } else { if (water && block.getBlockData() instanceof Waterlogged) { Waterlogged wl = (Waterlogged) block.getBlockData(); wl.setWaterlogged(true); @@ -185,8 +180,7 @@ public class Crucible extends SimpleSlimefunItem implements Rec if (times < 8) { SlimefunPlugin.runSync(() -> runPostTask(block, sound, times + 1), 50L); - } - else { + } else { block.getWorld().playSound(block.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java index bfdc7464b..44f16b9cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/EnhancedFurnace.java @@ -76,8 +76,7 @@ public class EnhancedFurnace extends SimpleSlimefunItem { if (b.getType() != Material.FURNACE) { // The Furnace has been destroyed, we can clear the block data BlockStorage.clearBlockInfo(b); - } - else { + } else { BlockStateSnapshotResult result = PaperLib.getBlockState(b, false); BlockState state = result.getState(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java index 8ef550897..003299059 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/blocks/RepairedSpawner.java @@ -79,7 +79,7 @@ public class RepairedSpawner extends SimpleSlimefunItem { return Optional.empty(); } - + @Override public Collection getDrops() { // There should be no drops by default since drops are handled by the diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java index ebd887788..56534ae8d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractCargoNode.java @@ -86,8 +86,7 @@ abstract class AbstractCargoNode extends SlimefunItem { if (newChannel < 0) { if (isChestTerminalInstalled) { newChannel = 16; - } - else { + } else { newChannel = 15; } } @@ -100,8 +99,7 @@ abstract class AbstractCargoNode extends SlimefunItem { if (channel == 16) { menu.replaceExistingItem(slotCurrent, new CustomItem(HeadTexture.CHEST_TERMINAL.getAsItemStack(), "&bChannel ID: &3" + (channel + 1))); menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); - } - else { + } else { menu.replaceExistingItem(slotCurrent, new CustomItem(MaterialCollections.getAllWoolColors().get(channel), "&bChannel ID: &3" + (channel + 1))); menu.addMenuClickHandler(slotCurrent, ChestMenuUtils.getEmptyClickHandler()); } @@ -114,8 +112,7 @@ abstract class AbstractCargoNode extends SlimefunItem { if (newChannel > 16) { newChannel = 0; } - } - else if (newChannel > 15) { + } else if (newChannel > 15) { newChannel = 0; } @@ -128,14 +125,12 @@ abstract class AbstractCargoNode extends SlimefunItem { private int getSelectedChannel(Block b) { if (!BlockStorage.hasBlockInfo(b)) { return 0; - } - else { + } else { String frequency = BlockStorage.getLocationInfo(b.getLocation(), FREQUENCY); if (frequency == null) { return 0; - } - else { + } else { int channel = Integer.parseInt(frequency); return NumberUtils.clamp(0, channel, 16); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java index 0be98adeb..991cfbc27 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/AbstractFilterNode.java @@ -74,8 +74,7 @@ abstract class AbstractFilterNode extends AbstractCargoNode { updateBlockMenu(menu, b); return false; }); - } - else { + } else { menu.replaceExistingItem(15, new CustomItem(Material.BLACK_WOOL, "&7Type: &8Blacklist", "", "&e> Click to change it to Whitelist")); menu.addMenuClickHandler(15, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_TYPE, "whitelist"); @@ -93,8 +92,7 @@ abstract class AbstractFilterNode extends AbstractCargoNode { updateBlockMenu(menu, b); return false; }); - } - else { + } else { menu.replaceExistingItem(25, new CustomItem(Material.MAP, "&7Include Lore: &4\u2718", "", "&e> Click to toggle whether the Lore has to match")); menu.addMenuClickHandler(25, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, FILTER_LORE, String.valueOf(true)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java index 13f46f541..a28646581 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoConnectorNode.java @@ -26,8 +26,7 @@ public class CargoConnectorNode extends SimpleSlimefunItem { if (CargoNet.getNetworkFromLocation(b.getLocation()) != null) { p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714")); - } - else { + } else { p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718")); } }; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java index a38a4b13d..56b55cd2b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoInputNode.java @@ -44,8 +44,7 @@ public class CargoInputNode extends AbstractFilterNode { updateBlockMenu(menu, b); return false; }); - } - else { + } else { menu.replaceExistingItem(24, new CustomItem(HeadTexture.ENERGY_REGULATOR.getAsItemStack(), "&7Round-Robin Mode: &2\u2714", "", "&e> Click to disable Round Robin Mode", "&e(Items will be equally distributed on the Channel)")); menu.addMenuClickHandler(24, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, ROUND_ROBIN_MODE, String.valueOf(false)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java index bd1e20633..7e64e252d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/CargoManager.java @@ -57,8 +57,7 @@ public class CargoManager extends SlimefunItem { if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) { BlockStorage.addBlockInfo(b, "visualizer", "disabled"); p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&4\u2718")); - } - else { + } else { BlockStorage.addBlockInfo(b, "visualizer", null); p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&cCargo Net Visualizer: " + "&2\u2714")); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java index 22420ca5a..fb07d176e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/cargo/ReactorAccessPort.java @@ -62,8 +62,7 @@ public class ReactorAccessPort extends SlimefunItem { return false; }); - } - else { + } else { menu.replaceExistingItem(INFO_SLOT, new CustomItem(Material.RED_WOOL, "&7Reactor", "", "&cNot detected", "", "&7Reactor must be", "&7placed 3 blocks below", "&7the access port!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { newInstance(menu, b); @@ -76,8 +75,7 @@ public class ReactorAccessPort extends SlimefunItem { public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { if (flow == ItemTransportFlow.INSERT) { return getInputSlots(); - } - else { + } else { return getOutputSlots(); } } @@ -87,12 +85,10 @@ public class ReactorAccessPort extends SlimefunItem { if (flow == ItemTransportFlow.INSERT) { if (SlimefunItem.getByItem(item) instanceof CoolantCell) { return getCoolantSlots(); - } - else { + } else { return getFuelSlots(); } - } - else { + } else { return getOutputSlots(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java index e66b2cb74..cba3f71cf 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiTool.java @@ -73,8 +73,7 @@ public class MultiTool extends SlimefunItem implements Rechargeable { sfItem.callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(e)); } } - } - else { + } else { index = nextIndex(index); SlimefunItem selectedItem = modes.get(index).getItem(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java index c3a16b706..e6c620eb0 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/gadgets/MultiToolMode.java @@ -11,7 +11,7 @@ class MultiToolMode { MultiToolMode(MultiTool multiTool, int id, String itemId) { this.item = new ItemSetting<>("mode." + id + ".item", itemId); this.enabled = new ItemSetting<>("mode." + id + ".enabled", true); - + multiTool.addItemSetting(item, enabled); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java index 14103d05b..942945155 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/generators/SolarGenerator.java @@ -71,18 +71,15 @@ public class SolarGenerator extends SlimefunItem implements EnergyNetProvider { if (world.getEnvironment() != Environment.NORMAL) { return 0; - } - else { + } else { boolean isDaytime = isDaytime(world); // Performance optimization for daytime-only solar generators if (!isDaytime && getNightEnergy() < 1) { return 0; - } - else if (!world.isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() < 15) { + } else if (!world.isChunkLoaded(l.getBlockX() >> 4, l.getBlockZ() >> 4) || l.getBlock().getLightFromSky() < 15) { return 0; - } - else { + } else { return isDaytime ? getDayEnergy() : getNightEnergy(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java index 0f4ff3ff0..664b43a0c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AbstractEntityAssembler.java @@ -95,8 +95,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { if (flow == ItemTransportFlow.INSERT) { return inputSlots; - } - else { + } else { return new int[0]; } } @@ -162,8 +161,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl updateBlockInventory(menu, b); return false; }); - } - else { + } else { menu.replaceExistingItem(22, new CustomItem(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine")); menu.addMenuClickHandler(22, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, KEY_ENABLED, String.valueOf(false)); @@ -254,8 +252,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl if (amount >= bodyCount) { inv.consumeItem(slot, bodyCount); break; - } - else { + } else { bodyCount -= amount; inv.replaceExistingItem(slot, null); } @@ -269,8 +266,7 @@ public abstract class AbstractEntityAssembler extends SimpleSl if (amount >= headCount) { inv.consumeItem(slot, headCount); break; - } - else { + } else { headCount -= amount; inv.replaceExistingItem(slot, null); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java index ab4d25641..78ef2961a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoBrewer.java @@ -90,8 +90,7 @@ public abstract class AutoBrewer extends AContainer { } return new MachineRecipe(30, new ItemStack[] { input1, input2 }, new ItemStack[] { output }); - } - else { + } else { return null; } } @@ -103,35 +102,28 @@ public abstract class AutoBrewer extends AContainer { if (input == Material.FERMENTED_SPIDER_EYE) { potion.setBasePotionData(new PotionData(PotionType.WEAKNESS, false, false)); return new ItemStack(potionType); - } - else if (input == Material.NETHER_WART) { + } else if (input == Material.NETHER_WART) { potion.setBasePotionData(new PotionData(PotionType.AWKWARD, false, false)); return new ItemStack(potionType); - } - else if (potionType == Material.POTION && input == Material.GUNPOWDER) { + } else if (potionType == Material.POTION && input == Material.GUNPOWDER) { return new ItemStack(Material.SPLASH_POTION); - } - else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) { + } else if (potionType == Material.SPLASH_POTION && input == Material.DRAGON_BREATH) { return new ItemStack(Material.LINGERING_POTION); } - } - else if (input == Material.FERMENTED_SPIDER_EYE) { + } else if (input == Material.FERMENTED_SPIDER_EYE) { PotionType fermented = fermentations.get(data.getType()); if (fermented != null) { potion.setBasePotionData(new PotionData(fermented, false, false)); return new ItemStack(potionType); } - } - else if (input == Material.REDSTONE) { + } else if (input == Material.REDSTONE) { potion.setBasePotionData(new PotionData(data.getType(), true, data.isUpgraded())); return new ItemStack(potionType); - } - else if (input == Material.GLOWSTONE_DUST) { + } else if (input == Material.GLOWSTONE_DUST) { potion.setBasePotionData(new PotionData(data.getType(), data.isExtended(), true)); return new ItemStack(potionType); - } - else if (data.getType() == PotionType.AWKWARD) { + } else if (data.getType() == PotionType.AWKWARD) { PotionType potionRecipe = potionRecipes.get(input); if (potionRecipe != null) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java index c7a145e0f..c61241b64 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutoDisenchanter.java @@ -108,7 +108,7 @@ public class AutoDisenchanter extends AContainer { EmeraldEnchants.getInstance().getRegistry().applyEnchantment(disenchantedItem, ench.getEnchantment(), 0); } - MachineRecipe recipe = new MachineRecipe(90 * amount / this.getSpeed() , new ItemStack[] { target, item }, new ItemStack[] { disenchantedItem, book }); + MachineRecipe recipe = new MachineRecipe(90 * amount / this.getSpeed(), new ItemStack[] { target, item }, new ItemStack[] { disenchantedItem, book }); if (!InvUtils.fitAll(menu.toInventory(), recipe.getOutput(), getOutputSlots())) { return null; @@ -152,8 +152,7 @@ public class AutoDisenchanter extends AContainer { else if (item.getType() != Material.BOOK) { SlimefunItem sfItem = SlimefunItem.getByItem(item); return sfItem == null || sfItem.isDisenchantable(); - } - else { + } else { return true; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java index 9b05adb57..7769f9cdb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/AutomatedCraftingChamber.java @@ -61,8 +61,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I newInstance(menu, b); return false; }); - } - else { + } else { menu.replaceExistingItem(6, new CustomItem(Material.REDSTONE, "&7Enabled: &2\u2714", "", "&e> Click to disable this Machine")); menu.addMenuClickHandler(6, (p, slot, item, action) -> { BlockStorage.addBlockInfo(b, "enabled", String.valueOf(false)); @@ -235,8 +234,10 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I ItemStack item = menu.getItemInSlot(getInputSlots()[j]); if (item != null && item.getAmount() == 1) { - if (craftLast) lastIteration = true; - else return ""; + if (craftLast) + lastIteration = true; + else + return ""; } builder.append(CustomItemSerializer.serialize(item, ItemFlag.MATERIAL, ItemFlag.ITEMMETA_DISPLAY_NAME, ItemFlag.ITEMMETA_LORE)); @@ -247,7 +248,8 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I // we're only executing the last possible shaped recipe // we don't want to allow this to be pressed instead of the default timer-based // execution to prevent abuse and auto clickers - if (craftLast && !lastIteration) return ""; + if (craftLast && !lastIteration) + return ""; return builder.toString(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java index 3ad79dd24..eb531682e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ChargingBench.java @@ -67,15 +67,13 @@ public class ChargingBench extends AContainer { if (((Rechargeable) sfItem).addItemCharge(item, charge)) { removeCharge(b.getLocation(), getEnergyConsumption()); - } - else if (inv.fits(item, getOutputSlots())) { + } else if (inv.fits(item, getOutputSlots())) { inv.pushItem(item, getOutputSlots()); inv.replaceExistingItem(slot, null); } return true; - } - else if (sfItem != null && inv.fits(item, getOutputSlots())) { + } else if (sfItem != null && inv.fits(item, getOutputSlots())) { inv.pushItem(item, getOutputSlots()); inv.replaceExistingItem(slot, null); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java index 1bdaaaa7f..4c0511710 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricDustWasher.java @@ -52,8 +52,7 @@ public abstract class ElectricDustWasher extends AContainer { menu.consumeItem(slot); return recipe; } - } - else if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) { + } else if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), SlimefunItems.PULVERIZED_ORE, true)) { MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] { SlimefunItems.PURE_ORE_CLUSTER }); if (menu.fits(recipe.getOutput()[0], getOutputSlots())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java index 8df9d45bd..11422c220 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricGoldPan.java @@ -56,8 +56,7 @@ public abstract class ElectricGoldPan extends AContainer implements RecipeDispla menu.consumeItem(slot); return recipe; } - } - else if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, false)) { + } else if (SlimefunUtils.isItemSimilar(menu.getItemInSlot(slot), new ItemStack(Material.SOUL_SAND), true, false)) { ItemStack output = netherGoldPan.getRandomOutput(); MachineRecipe recipe = new MachineRecipe(4 / getSpeed(), new ItemStack[0], new ItemStack[] { output }); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java index 13cacf61c..5e7671af1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/ElectricSmeltery.java @@ -83,12 +83,10 @@ public abstract class ElectricSmeltery extends AContainer { if (slots.isEmpty()) { return getInputSlots(); - } - else if (fullSlots == slots.size()) { + } else if (fullSlots == slots.size()) { // All slots with that item are already full return new int[0]; - } - else { + } else { Collections.sort(slots, compareSlots(menu)); int[] array = new int[slots.size()]; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java index 3c6960594..c2a0a9044 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/FluidPump.java @@ -151,8 +151,7 @@ public class FluidPump extends SimpleSlimefunItem implements Invent if (isSource(fluid)) { return fluid; } - } - else if (fluid.getType() == Material.LAVA) { + } else if (fluid.getType() == Material.LAVA) { List list = Vein.find(fluid, RANGE, block -> block.getType() == fluid.getType()); for (int i = list.size() - 1; i >= 0; i--) { @@ -169,11 +168,9 @@ public class FluidPump extends SimpleSlimefunItem implements Invent private ItemStack getFilledBucket(Block fluid) { if (fluid.getType() == Material.LAVA) { return new ItemStack(Material.LAVA_BUCKET); - } - else if (fluid.getType() == Material.WATER || fluid.getType() == Material.BUBBLE_COLUMN) { + } else if (fluid.getType() == Material.WATER || fluid.getType() == Material.BUBBLE_COLUMN) { return new ItemStack(Material.WATER_BUCKET); - } - else { + } else { // Fallback for any new liquids return new ItemStack(Material.BUCKET); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java index 4d1e123aa..69e2ee900 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/HeatedPressureChamber.java @@ -61,8 +61,7 @@ public abstract class HeatedPressureChamber extends AContainer { if (slots.isEmpty()) { return getInputSlots(); - } - else { + } else { Collections.sort(slots, compareSlots(menu)); int[] array = new int[slots.size()]; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java index 93af5064a..fcd6df495 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/machines/XPCollector.java @@ -137,8 +137,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock, EnergyN if (value != null) { return Integer.parseInt(value); - } - else { + } else { BlockStorage.addBlockInfo(b, DATA_KEY, "0"); return 0; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java index e16f2d299..f595891a8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/electric/reactors/Reactor.java @@ -159,8 +159,7 @@ public abstract class Reactor extends AbstractEnergyProvider { return false; }); - } - else { + } else { menu.replaceExistingItem(INFO_SLOT, new CustomItem(Material.RED_WOOL, "&7Access Port", "", "&cNot detected", "", "&7Access Port must be", "&7placed 3 blocks above", "&7a reactor!")); menu.addMenuClickHandler(INFO_SLOT, (p, slot, item, action) -> { updateInventory(menu, b); @@ -193,8 +192,7 @@ public abstract class Reactor extends AbstractEnergyProvider { if (needsCooling()) { preset.addItem(7, new CustomItem(getCoolant(), "&bCoolant Slot", "", "&fThis Slot accepts Coolant Cells", "&4Without any Coolant Cells, your Reactor", "&4will explode")); - } - else { + } else { preset.addItem(7, new CustomItem(Material.BARRIER, "&bCoolant Slot", "", "&fThis Slot accepts Coolant Cells")); for (int i : border_4) { @@ -284,13 +282,11 @@ public abstract class Reactor extends AbstractEnergyProvider { if (timeleft > 0) { return generateEnergy(l, data, inv, accessPort, timeleft); - } - else { + } else { createByproduct(l, inv, accessPort); return 0; } - } - else { + } else { burnNextFuel(l, inv, accessPort); return 0; } @@ -321,8 +317,7 @@ public abstract class Reactor extends AbstractEnergyProvider { if (space >= produced) { return getEnergyProduction(); - } - else { + } else { return 0; } } @@ -438,8 +433,7 @@ public abstract class Reactor extends AbstractEnergyProvider { } return false; - } - else { + } else { ReactorHologram.update(reactor, "&b\u2744 &7" + getPercentage(timeleft, processing.get(reactor).getTicks()) + "%"); } @@ -484,8 +478,7 @@ public abstract class Reactor extends AbstractEnergyProvider { if (BlockStorage.check(port, SlimefunItems.REACTOR_ACCESS_PORT.getItemId())) { return BlockStorage.getInventory(port); - } - else { + } else { return null; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java index 7f2592ed4..b458ac0dc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/food/Juice.java @@ -47,8 +47,7 @@ public class Juice extends SimpleSlimefunItem { if (meta instanceof PotionMeta) { effects = ((PotionMeta) meta).getCustomEffects(); - } - else { + } else { effects = new ArrayList<>(); } } @@ -82,16 +81,13 @@ public class Juice extends SimpleSlimefunItem { if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInMainHand(), true)) { if (p.getInventory().getItemInMainHand().getAmount() == 1) { SlimefunPlugin.runSync(() -> p.getEquipment().getItemInMainHand().setAmount(0)); - } - else { + } else { SlimefunPlugin.runSync(() -> p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1))); } - } - else if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInOffHand(), true)) { + } else if (SlimefunUtils.isItemSimilar(item, p.getInventory().getItemInOffHand(), true)) { if (p.getInventory().getItemInOffHand().getAmount() == 1) { SlimefunPlugin.runSync(() -> p.getEquipment().getItemInOffHand().setAmount(0)); - } - else { + } else { SlimefunPlugin.runSync(() -> p.getInventory().removeItem(new ItemStack(Material.GLASS_BOTTLE, 1))); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java index f6e2aaa20..70ca06c60 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOMiner.java @@ -148,19 +148,16 @@ public abstract class GEOMiner extends AContainer implements RecipeDisplayItem { removeCharge(b.getLocation(), getEnergyConsumption()); progress.put(b, timeleft - 1); - } - else { + } else { inv.replaceExistingItem(4, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " ")); inv.pushItem(processing.get(b).getOutput()[0], getOutputSlots()); progress.remove(b); processing.remove(b); } - } - else if (!BlockStorage.hasChunkInfo(b.getWorld(), b.getX() >> 4, b.getZ() >> 4)) { + } else if (!BlockStorage.hasChunkInfo(b.getWorld(), b.getX() >> 4, b.getZ() >> 4)) { SimpleHologram.update(b, "&4GEO-Scan required!"); - } - else { + } else { start(b, inv); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java index de00637ad..63e61042b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/GEOScanner.java @@ -1,8 +1,15 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.geo; +import java.util.Optional; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Location; import org.bukkit.block.Block; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -19,10 +26,25 @@ public class GEOScanner extends SimpleSlimefunItem { @Override public BlockUseHandler getItemHandler() { return e -> { - Block b = e.getClickedBlock().get(); - e.cancel(); - SlimefunPlugin.getGPSNetwork().getResourceManager().scan(e.getPlayer(), b, 0); + + Player p = e.getPlayer(); + Optional block = e.getClickedBlock(); + + if (block.isPresent()) { + Block b = block.get(); + + if (hasAccess(p, b.getLocation())) { + SlimefunPlugin.getGPSNetwork().getResourceManager().scan(p, b, 0); + } else { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + } + } }; } + + @ParametersAreNonnullByDefault + private boolean hasAccess(Player p, Location l) { + return p.hasPermission("slimefun.gps.bypass") || (SlimefunPlugin.getProtectionManager().hasPermission(p, l, ProtectableAction.ACCESS_INVENTORIES)); + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java index 5f3c1aa1c..899d4db6a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/geo/OilPump.java @@ -59,8 +59,7 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem { public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { if (flow == ItemTransportFlow.INSERT) { return getInputSlots(); - } - else { + } else { return getOutputSlots(); } } @@ -97,8 +96,7 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem { inv.consumeItem(slot); SlimefunPlugin.getGPSNetwork().getResourceManager().setSupplies(oil, b.getWorld(), b.getX() >> 4, b.getZ() >> 4, supplies.getAsInt() - 1); return recipe; - } - else { + } else { // Move the empty bucket to the output slot to prevent this // from immediately starting all over again (to prevent lag) ItemStack item = inv.getItemInSlot(slot).clone(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java index 275c94b4a..78c8f9c80 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/ElevatorPlate.java @@ -105,8 +105,7 @@ public class ElevatorPlate extends SimpleSlimefunItem { if (floors.size() < 2) { SlimefunPlugin.getLocalization().sendMessage(p, "machines.ELEVATOR.no-destinations", true); - } - else { + } else { openFloorSelector(b, floors, p); } } @@ -132,8 +131,7 @@ public class ElevatorPlate extends SimpleSlimefunItem { if (block.getY() == b.getY()) { line = new ChatComponent("\n" + ChatColor.GRAY + "> " + (floors.size() - i) + ". " + ChatColor.BLACK + floor); line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.current-floor")), "", ChatColor.WHITE + floor, "")); - } - else { + } else { line = new ChatComponent("\n" + ChatColor.GRAY + (floors.size() - i) + ". " + ChatColor.BLACK + floor); line.setHoverEvent(new HoverEvent(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.ELEVATOR.click-to-teleport")), "", ChatColor.WHITE + floor, "")); line.setClickEvent(new ClickEvent(new NamespacedKey(SlimefunPlugin.instance(), DATA_KEY + i), player -> teleport(player, floor, block))); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java index 4d11de893..27d771eba 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSControlPanel.java @@ -1,7 +1,15 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.gps; +import java.util.Optional; + +import javax.annotation.ParametersAreNonnullByDefault; + +import org.bukkit.Location; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction; import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler; import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem; @@ -17,6 +25,24 @@ public class GPSControlPanel extends SimpleSlimefunItem { @Override public BlockUseHandler getItemHandler() { - return e -> SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(e.getPlayer()); + return e -> { + e.cancel(); + + Player p = e.getPlayer(); + Optional block = e.getClickedBlock(); + + if (block.isPresent()) { + if (hasAccess(p, block.get().getLocation())) { + SlimefunPlugin.getGPSNetwork().openTransmitterControlPanel(p); + } else { + SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); + } + } + }; + } + + @ParametersAreNonnullByDefault + private boolean hasAccess(Player p, Location l) { + return p.hasPermission("slimefun.gps.bypass") || (SlimefunPlugin.getProtectionManager().hasPermission(p, l, ProtectableAction.ACCESS_INVENTORIES)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java index 594dde304..0bb9da670 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/gps/GPSTransmitter.java @@ -66,8 +66,7 @@ public abstract class GPSTransmitter extends SimpleSlimefunItem imp if (charge >= getEnergyConsumption()) { SlimefunPlugin.getGPSNetwork().updateTransmitter(b.getLocation(), owner, true); removeCharge(b.getLocation(), getEnergyConsumption()); - } - else { + } else { SlimefunPlugin.getGPSNetwork().updateTransmitter(b.getLocation(), owner, false); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java index 081636866..7cf3a4362 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/EnchantmentRune.java @@ -70,8 +70,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { SlimefunPlugin.runSync(() -> { try { addRandomEnchantment(p, item); - } - catch (Exception x) { + } catch (Exception x) { error("An Exception occurred while trying to apply an Enchantment Rune", x); } }, 20L); @@ -103,8 +102,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { if (potentialEnchantments == null) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.enchantment-rune.fail", true); return; - } - else { + } else { potentialEnchantments = new ArrayList<>(potentialEnchantments); } @@ -140,8 +138,7 @@ public class EnchantmentRune extends SimpleSlimefunItem { SlimefunPlugin.getLocalization().sendMessage(p, "messages.enchantment-rune.success", true); } }, 10L); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.enchantment-rune.fail", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java index ed923bc6d..b2a0997aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/KnowledgeTome.java @@ -45,8 +45,7 @@ public class KnowledgeTome extends SimpleSlimefunItem { im.setLore(lore); item.setItemMeta(im); p.getWorld().playSound(p.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1F, 1F); - } - else { + } else { UUID uuid = UUID.fromString(ChatColor.stripColor(item.getItemMeta().getLore().get(1))); if (p.getUniqueId().equals(uuid)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java index b8163c176..15c476ad1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicEyeOfEnder.java @@ -35,9 +35,6 @@ public class MagicEyeOfEnder extends SimpleSlimefunItem { } private boolean hasArmor(PlayerInventory inv) { - return SlimefunUtils.isItemSimilar(inv.getHelmet(), SlimefunItems.ENDER_HELMET, true) - && SlimefunUtils.isItemSimilar(inv.getChestplate(), SlimefunItems.ENDER_CHESTPLATE, true) - && SlimefunUtils.isItemSimilar(inv.getLeggings(), SlimefunItems.ENDER_LEGGINGS, true) - && SlimefunUtils.isItemSimilar(inv.getBoots(), SlimefunItems.ENDER_BOOTS, true); + return SlimefunUtils.isItemSimilar(inv.getHelmet(), SlimefunItems.ENDER_HELMET, true) && SlimefunUtils.isItemSimilar(inv.getChestplate(), SlimefunItems.ENDER_CHESTPLATE, true) && SlimefunUtils.isItemSimilar(inv.getLeggings(), SlimefunItems.ENDER_LEGGINGS, true) && SlimefunUtils.isItemSimilar(inv.getBoots(), SlimefunItems.ENDER_BOOTS, true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java index 5d114ee63..b3e96e4d3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/MagicalZombiePills.java @@ -55,8 +55,7 @@ public class MagicalZombiePills extends SimpleSlimefunItem { l.getWorld().dropItemNaturally(l, itemStack); SlimefunPlugin.getLocalization().sendMessage(p, "messages.soulbound-rune.success", true); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.soulbound-rune.fail", true); } }, 10L); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.soulbound-rune.fail", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java index 5c72e5ceb..11a69daac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/StormStaff.java @@ -75,13 +75,11 @@ public class StormStaff extends SimpleSlimefunItem { if (loc.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(p, loc, ProtectableAction.PVP)) { e.cancel(); useItem(p, item, loc); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.no-pvp", true); } } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.hungry", true); } }; @@ -122,16 +120,14 @@ public class StormStaff extends SimpleSlimefunItem { // or throw it on the ground p.getWorld().dropItemNaturally(p.getLocation(), seperateItem); } - } - else { + } else { ItemMeta meta = item.getItemMeta(); int usesLeft = meta.getPersistentDataContainer().getOrDefault(usageKey, PersistentDataType.INTEGER, MAX_USES); if (usesLeft == 1) { p.playSound(p.getLocation(), Sound.ENTITY_ITEM_BREAK, 1, 1); item.setAmount(0); - } - else { + } else { usesLeft--; meta.getPersistentDataContainer().set(usageKey, PersistentDataType.INTEGER, usesLeft); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java index c8bb06d9a..6ba3cddda 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/WindStaff.java @@ -30,7 +30,7 @@ public class WindStaff extends SimpleSlimefunItem { if (isItem(e.getItem()) && p.getGameMode() != GameMode.CREATIVE) { FoodLevelChangeEvent event = new FoodLevelChangeEvent(p, p.getFoodLevel() - 2); Bukkit.getPluginManager().callEvent(event); - + if (!event.isCancelled()) { p.setFoodLevel(event.getFoodLevel()); } @@ -40,8 +40,7 @@ public class WindStaff extends SimpleSlimefunItem { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1); p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1); p.setFallDistance(0F); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.hungry", true); } }; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java index 24bbd93e1..9e17b1619 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/MagicianTalisman.java @@ -27,8 +27,7 @@ public class MagicianTalisman extends Talisman { for (int i = 1; i <= enchantment.getMaxLevel(); 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); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java index 893a441f5..f4768952a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/magical/talismans/Talisman.java @@ -80,8 +80,7 @@ public class Talisman extends SlimefunItem { } enderTalisman = new SlimefunItemStack("ENDER_" + getID(), getItem().getType(), name, lore.toArray(new String[0])); - } - else { + } else { enderTalisman = null; } } @@ -163,6 +162,7 @@ public class Talisman extends SlimefunItem { } if (SlimefunUtils.containsSimilarItem(p.getInventory(), talismanItem, true)) { +<<<<<<< HEAD activateTalisman(e, p, p.getInventory(), talisman); return retrieveTalismanFromInventory(p.getInventory(), talisman); } @@ -182,6 +182,26 @@ public class Talisman extends SlimefunItem { if (SlimefunUtils.isItemSimilar(item, talisman.getItem(), true, false)) { return item; +======= + if (Slimefun.hasUnlocked(p, talisman, true)) { + activateTalisman(e, p, p.getInventory(), talisman); + return true; + } else { + return false; + } + } else { + ItemStack enderTalisman = talisman.getEnderVariant(); + + if (SlimefunUtils.containsSimilarItem(p.getEnderChest(), enderTalisman, true)) { + if (Slimefun.hasUnlocked(p, talisman, true)) { + activateTalisman(e, p, p.getEnderChest(), talisman); + return true; + } else { + return false; + } + } else { + return false; +>>>>>>> 20405a775bfe896f09d8c4793451ae75d254255a } } @@ -237,20 +257,15 @@ public class Talisman extends SlimefunItem { } else if (e instanceof EntityDeathEvent) { return ((EntityDeathEvent) e).getEntity().getKiller(); - } - else if (e instanceof BlockBreakEvent) { + } else if (e instanceof BlockBreakEvent) { return ((BlockBreakEvent) e).getPlayer(); - } - else if (e instanceof BlockDropItemEvent) { + } else if (e instanceof BlockDropItemEvent) { return ((BlockDropItemEvent) e).getPlayer(); - } - else if (e instanceof PlayerEvent) { + } else if (e instanceof PlayerEvent) { return ((PlayerEvent) e).getPlayer(); - } - else if (e instanceof EntityEvent) { + } else if (e instanceof EntityEvent) { return (Player) ((EntityEvent) e).getEntity(); - } - else if (e instanceof EnchantItemEvent) { + } else if (e instanceof EnchantItemEvent) { return ((EnchantItemEvent) e).getEnchanter(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java index e619b5b8e..a3e5fdbbb 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/medical/MedicalSupply.java @@ -31,14 +31,22 @@ public abstract class MedicalSupply extends SimpleSlimefu * The {@link LivingEntity} to clear the effects from. */ public void clearNegativeEffects(@Nonnull LivingEntity n) { - if (n.hasPotionEffect(PotionEffectType.POISON)) n.removePotionEffect(PotionEffectType.POISON); - if (n.hasPotionEffect(PotionEffectType.WITHER)) n.removePotionEffect(PotionEffectType.WITHER); - if (n.hasPotionEffect(PotionEffectType.SLOW)) n.removePotionEffect(PotionEffectType.SLOW); - if (n.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) n.removePotionEffect(PotionEffectType.SLOW_DIGGING); - if (n.hasPotionEffect(PotionEffectType.WEAKNESS)) n.removePotionEffect(PotionEffectType.WEAKNESS); - if (n.hasPotionEffect(PotionEffectType.CONFUSION)) n.removePotionEffect(PotionEffectType.CONFUSION); - if (n.hasPotionEffect(PotionEffectType.BLINDNESS)) n.removePotionEffect(PotionEffectType.BLINDNESS); - if (n.hasPotionEffect(PotionEffectType.BAD_OMEN)) n.removePotionEffect(PotionEffectType.BAD_OMEN); + if (n.hasPotionEffect(PotionEffectType.POISON)) + n.removePotionEffect(PotionEffectType.POISON); + if (n.hasPotionEffect(PotionEffectType.WITHER)) + n.removePotionEffect(PotionEffectType.WITHER); + if (n.hasPotionEffect(PotionEffectType.SLOW)) + n.removePotionEffect(PotionEffectType.SLOW); + if (n.hasPotionEffect(PotionEffectType.SLOW_DIGGING)) + n.removePotionEffect(PotionEffectType.SLOW_DIGGING); + if (n.hasPotionEffect(PotionEffectType.WEAKNESS)) + n.removePotionEffect(PotionEffectType.WEAKNESS); + if (n.hasPotionEffect(PotionEffectType.CONFUSION)) + n.removePotionEffect(PotionEffectType.CONFUSION); + if (n.hasPotionEffect(PotionEffectType.BLINDNESS)) + n.removePotionEffect(PotionEffectType.BLINDNESS); + if (n.hasPotionEffect(PotionEffectType.BAD_OMEN)) + n.removePotionEffect(PotionEffectType.BAD_OMEN); } /** diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java index a0b97afd4..632e95f0a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AbstractSmeltery.java @@ -53,8 +53,7 @@ abstract class AbstractSmeltery extends MultiBlockMachine { if (outputInv != null) { craft(p, b, inv, inputs.get(i), output, outputInv); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } } @@ -73,8 +72,7 @@ abstract class AbstractSmeltery extends MultiBlockMachine { for (int j = 0; j < inv.getContents().length; j++) { if (j == (inv.getContents().length - 1) && !SlimefunUtils.isItemSimilar(inv.getContents()[j], expectedInput, true)) { return false; - } - else if (SlimefunUtils.isItemSimilar(inv.getContents()[j], expectedInput, true)) { + } else if (SlimefunUtils.isItemSimilar(inv.getContents()[j], expectedInput, true)) { break; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java index 189592597..1cb865b36 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/ArmorForge.java @@ -48,8 +48,7 @@ public class ArmorForge extends MultiBlockMachine { if (outputInv != null) { craft(p, output, inv, outputInv); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } } @@ -87,8 +86,7 @@ public class ArmorForge extends MultiBlockMachine { SlimefunPlugin.runSync(() -> { if (current < 3) { p.getWorld().playSound(p.getLocation(), Sound.BLOCK_ANVIL_USE, 1F, 2F); - } - else { + } else { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); outputInv.addItem(output); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java index fb7f4ceff..17a6c9706 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/AutomatedPanningMachine.java @@ -64,21 +64,18 @@ public class AutomatedPanningMachine extends MultiBlockMachine { if (outputChest != null) { outputChest.addItem(output.clone()); - } - else { + } else { b.getWorld().dropItemNaturally(b.getLocation(), output.clone()); } p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); - } - else { + } else { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARMOR_STAND_BREAK, 1F, 1F); } }); queue.execute(SlimefunPlugin.instance()); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java index 89c537f04..1a7615221 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/BackpackCrafter.java @@ -83,8 +83,7 @@ abstract class BackpackCrafter extends MultiBlockMachine { break; } } - } - else { + } else { for (int line = 0; line < output.getItemMeta().getLore().size(); line++) { if (output.getItemMeta().getLore().get(line).equals(ChatColors.color("&7ID: "))) { int target = line; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java index 4d467b340..a58351c0c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Compressor.java @@ -64,8 +64,7 @@ public class Compressor extends MultiBlockMachine { inv.removeItem(removing); craft(p, output, outputInv); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } @@ -85,8 +84,7 @@ public class Compressor extends MultiBlockMachine { SlimefunPlugin.runSync(() -> { if (j < 3) { p.getWorld().playSound(p.getLocation(), j == 1 ? Sound.BLOCK_PISTON_CONTRACT : Sound.BLOCK_PISTON_EXTEND, 1F, j == 0 ? 1F : 2F); - } - else { + } else { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); outputInv.addItem(output); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java index 7ad597a36..b03a4f182 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/EnhancedCraftingTable.java @@ -78,8 +78,7 @@ public class EnhancedCraftingTable extends BackpackCrafter { outputInv.addItem(output); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } } @@ -91,8 +90,7 @@ public class EnhancedCraftingTable extends BackpackCrafter { if (!SlimefunUtils.isItemSimilar(inv.getContents()[j], recipe[j], false)) { return false; } - } - else { + } else { return false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java index 6bb98ec35..3c1533a98 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/GrindStone.java @@ -99,8 +99,7 @@ public class GrindStone extends MultiBlockMachine { inv.removeItem(removing); outputInv.addItem(output); p.getWorld().playSound(p.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java index abd6e6f4d..9070b3de4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Juicer.java @@ -56,8 +56,7 @@ public class Juicer extends MultiBlockMachine { outputInv.addItem(adding); p.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1F, 1F); p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.HAY_BLOCK); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java index 5b6ed3bd8..c3ffd22df 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/MagicWorkbench.java @@ -77,16 +77,14 @@ public class MagicWorkbench extends BackpackCrafter { if (inv.getContents()[j] != null && inv.getContents()[j].getType() != Material.AIR) { if (inv.getContents()[j].getAmount() > 1) { inv.setItem(j, new CustomItem(inv.getContents()[j], inv.getContents()[j].getAmount() - 1)); - } - else { + } else { inv.setItem(j, null); } } } startAnimation(p, b, outputInv, output); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } } @@ -100,8 +98,7 @@ public class MagicWorkbench extends BackpackCrafter { if (current < 3) { p.getWorld().playSound(b.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1F, 1F); - } - else { + } else { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); inv.addItem(output); } @@ -114,14 +111,11 @@ public class MagicWorkbench extends BackpackCrafter { if (b.getRelative(1, 0, 0).getType() == Material.DISPENSER) { block = b.getRelative(1, 0, 0); - } - else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) { + } else if (b.getRelative(0, 0, 1).getType() == Material.DISPENSER) { block = b.getRelative(0, 0, 1); - } - else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) { + } else if (b.getRelative(-1, 0, 0).getType() == Material.DISPENSER) { block = b.getRelative(-1, 0, 0); - } - else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) { + } else if (b.getRelative(0, 0, -1).getType() == Material.DISPENSER) { block = b.getRelative(0, 0, -1); } @@ -135,8 +129,7 @@ public class MagicWorkbench extends BackpackCrafter { if (!SlimefunUtils.isItemSimilar(inv.getContents()[j], recipe[j], false)) { return false; } - } - else { + } else { return false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java index d0f93c00c..bb857f3d5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreCrusher.java @@ -142,8 +142,7 @@ public class OreCrusher extends MultiBlockMachine { inv.removeItem(removing); outputInv.addItem(adding); p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, 1); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java index 1fdfc48aa..94f7c07ae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/OreWasher.java @@ -34,7 +34,7 @@ public class OreWasher extends MultiBlockMachine { legacyMode = SlimefunPlugin.getCfg().getBoolean("options.legacy-ore-washer"); dusts = new ItemStack[] { SlimefunItems.IRON_DUST, SlimefunItems.GOLD_DUST, SlimefunItems.COPPER_DUST, SlimefunItems.TIN_DUST, SlimefunItems.ZINC_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.MAGNESIUM_DUST, SlimefunItems.LEAD_DUST, SlimefunItems.SILVER_DUST }; } - + @Override protected void registerDefaultRecipes(List recipes) { // Iron and Gold are displayed as Ore Crusher recipes, as that is their primary @@ -78,8 +78,7 @@ public class OreWasher extends MultiBlockMachine { // not supposed to be given to the player. ItemStack dummyAdding = SlimefunItems.DEBUG_FISH; outputInv = findOutputInventory(dummyAdding, dispBlock, inv); - } - else { + } else { outputInv = findOutputInventory(output, dispBlock, inv); } @@ -90,16 +89,14 @@ public class OreWasher extends MultiBlockMachine { } return; - } - else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) { + } else if (SlimefunUtils.isItemSimilar(input, new ItemStack(Material.SAND, 2), false)) { ItemStack output = SlimefunItems.SALT; Inventory outputInv = findOutputInventory(output, dispBlock, inv); removeItem(p, b, inv, outputInv, input, output, 2); return; - } - else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) { + } else if (SlimefunUtils.isItemSimilar(input, SlimefunItems.PULVERIZED_ORE, true)) { ItemStack output = SlimefunItems.PURE_ORE_CLUSTER; Inventory outputInv = findOutputInventory(output, dispBlock, inv); @@ -122,8 +119,7 @@ public class OreWasher extends MultiBlockMachine { b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, Material.WATER); b.getWorld().playSound(b.getLocation(), Sound.ENTITY_PLAYER_SPLASH, 1, 1); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java index de4cedb38..4395387c8 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/PressureChamber.java @@ -57,8 +57,7 @@ public class PressureChamber extends MultiBlockMachine { inv.removeItem(removing); craft(p, b, output, outputInv); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true); } @@ -82,8 +81,7 @@ public class PressureChamber extends MultiBlockMachine { if (j < 3) { p.getWorld().playSound(b.getLocation(), Sound.ENTITY_TNT_PRIMED, 1F, 1F); - } - else { + } else { p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1F, 1F); outputInv.addItem(output); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java index 4225218dc..e5a0c8d01 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/Smeltery.java @@ -88,16 +88,14 @@ public class Smeltery extends AbstractSmeltery { } p.getWorld().playSound(p.getLocation(), Sound.ITEM_FLINTANDSTEEL_USE, 1, 1); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "machines.ignition-chamber-no-flint", true); Block fire = b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN); fire.getWorld().playEffect(fire.getLocation(), Effect.STEP_SOUND, fire.getType()); fire.setType(Material.AIR); } - } - else { + } else { Block fire = b.getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN); fire.getWorld().playEffect(fire.getLocation(), Effect.STEP_SOUND, fire.getType()); fire.setType(Material.AIR); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java index 22caf32c7..315734586 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/TableSaw.java @@ -4,6 +4,9 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + import org.bukkit.Effect; import org.bukkit.GameMode; import org.bukkit.Material; @@ -17,6 +20,7 @@ import org.bukkit.inventory.ItemStack; import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils; import io.github.thebusybiscuit.cscorelib2.materials.MaterialConverter; import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; import me.mrCookieSlime.Slimefun.Objects.Category; import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; @@ -27,6 +31,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack; * It also replaced the old "Saw Mill" from earlier versions. * * @author dniym + * @author svr333 * * @see MultiBlockMachine * @@ -46,6 +51,11 @@ public class TableSaw extends MultiBlockMachine { displayedRecipes.add(new ItemStack(planks.get(), 8)); } } + + for (Material plank : Tag.PLANKS.getValues()) { + displayedRecipes.add(new ItemStack(plank)); + displayedRecipes.add(new ItemStack(Material.STICK, 4)); + } } @Override @@ -54,28 +64,47 @@ public class TableSaw extends MultiBlockMachine { } @Override - public void onInteract(Player p, Block b) { - ItemStack log = p.getInventory().getItemInMainHand(); + public void onInteract(@Nonnull Player p, @Nonnull Block b) { + ItemStack item = p.getInventory().getItemInMainHand(); + ItemStack output = getOutputFromMaterial(item.getType()); - Optional planks = MaterialConverter.getPlanksFromLog(log.getType()); + if (output == null) { + SlimefunPlugin.getLocalization().sendMessage(p, "machines.wrong-item", true); + return; + } - if (planks.isPresent()) { - if (p.getGameMode() != GameMode.CREATIVE) { - ItemUtils.consumeItem(log, true); + if (p.getGameMode() != GameMode.CREATIVE) { + ItemUtils.consumeItem(item, true); + } + + outputItems(b, output); + b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, item.getType()); + } + + @Nullable + private ItemStack getOutputFromMaterial(@Nonnull Material item) { + if (Tag.LOGS.isTagged(item)) { + Optional planks = MaterialConverter.getPlanksFromLog(item); + + if (planks.isPresent()) { + return new ItemStack(planks.get(), 8); + } else { + return null; } - - ItemStack output = new ItemStack(planks.get(), 8); - Inventory outputChest = findOutputChest(b, output); - - if (outputChest != null) { - outputChest.addItem(output); - } - else { - b.getWorld().dropItemNaturally(b.getLocation(), output); - } - - b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, log.getType()); + } else if (Tag.PLANKS.isTagged(item)) { + return new ItemStack(Material.STICK, 4); + } else { + return null; } } + private void outputItems(@Nonnull Block b, @Nonnull ItemStack output) { + Inventory outputChest = findOutputChest(b, output); + + if (outputChest != null) { + outputChest.addItem(output); + } else { + b.getWorld().dropItemNaturally(b.getLocation(), output); + } + } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java index 06fc54f83..9c548d7f2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/ActiveMiner.java @@ -197,8 +197,7 @@ class ActiveMiner implements Runnable { } 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)); stop(); } @@ -213,12 +212,10 @@ class ActiveMiner implements Runnable { private void nextColumn() { if (x < end.getX()) { x++; - } - else if (z < end.getZ()) { + } else if (z < end.getZ()) { x = start.getX(); z++; - } - else { + } else { // The Miner has finished stop(); @@ -261,22 +258,18 @@ class ActiveMiner implements Runnable { if (InvUtils.fits(inv, item)) { inv.addItem(item); return true; - } - else { + } else { stop("machines.INDUSTRIAL_MINER.chest-full"); } - } - else { + } else { // I won't question how this happened... stop("machines.INDUSTRIAL_MINER.destroyed"); } - } - else { + } else { // The chest has been destroyed stop("machines.INDUSTRIAL_MINER.destroyed"); } - } - else { + } else { stop("machines.INDUSTRIAL_MINER.no-fuel"); } @@ -334,8 +327,7 @@ class ActiveMiner implements Runnable { if (block.getType() == Material.MOVING_PISTON) { // Yeah it isn't really cool when this happens block.getRelative(BlockFace.UP).setType(Material.AIR); - } - else if (block.getType() == Material.PISTON) { + } else if (block.getType() == Material.PISTON) { Block above = block.getRelative(BlockFace.UP); // Check if the above block is valid @@ -345,23 +337,19 @@ class ActiveMiner implements Runnable { // Check if the piston is actually facing upwards if (piston.getFacing() == BlockFace.UP) { setExtended(block, piston, extended); - } - else { + } else { // The pistons must be facing upwards stop("machines.INDUSTRIAL_MINER.piston-facing"); } - } - else { + } else { // The pistons must be facing upwards stop("machines.INDUSTRIAL_MINER.piston-space"); } - } - else { + } else { // The piston has been 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)); stop(); } @@ -377,8 +365,7 @@ class ActiveMiner implements Runnable { head.setFacing(BlockFace.UP); block.getRelative(BlockFace.UP).setBlockData(head, false); - } - else { + } else { block.getRelative(BlockFace.UP).setType(Material.AIR); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java index 4e4a54301..e23df42f3 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/multiblocks/miner/IndustrialMiner.java @@ -195,8 +195,7 @@ public class IndustrialMiner extends MultiBlockMachine { if (northern.getType() == Material.PISTON) { return new Block[] { northern, chest.getRelative(BlockFace.SOUTH) }; - } - else { + } else { return new Block[] { chest.getRelative(BlockFace.WEST), chest.getRelative(BlockFace.EAST) }; } } @@ -212,12 +211,10 @@ public class IndustrialMiner extends MultiBlockMachine { public boolean canMine(Material type) { if (type.name().endsWith("_ORE")) { return true; - } - else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { + } else if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) { if (type == Material.GILDED_BLACKSTONE) { return true; - } - else if (type == Material.ANCIENT_DEBRIS) { + } else if (type == Material.ANCIENT_DEBRIS) { return canMineAncientDebris.getValue(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java index 9a6e23676..c5d53c4ac 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ClimbingPick.java @@ -131,8 +131,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements private ItemStack getOtherHandItem(Player p, EquipmentSlot hand) { if (hand == EquipmentSlot.HAND) { return p.getInventory().getItemInOffHand(); - } - else { + } else { return p.getInventory().getItemInMainHand(); } } @@ -161,8 +160,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements swing(p, block, hand, item); } } - } - else if (!isDualWieldingEnabled() || hand == EquipmentSlot.HAND) { + } else if (!isDualWieldingEnabled() || hand == EquipmentSlot.HAND) { // We don't wanna send the message twice, so we check for dual wielding SlimefunPlugin.getLocalization().sendMessage(p, "messages.climbing-pick.wrong-material"); } @@ -174,13 +172,11 @@ public class ClimbingPick extends SimpleSlimefunItem implements if (ThreadLocalRandom.current().nextBoolean()) { damageItem(p, p.getInventory().getItemInMainHand()); playAnimation(p, b, EquipmentSlot.HAND); - } - else { + } else { damageItem(p, p.getInventory().getItemInOffHand()); playAnimation(p, b, EquipmentSlot.OFF_HAND); } - } - else { + } else { damageItem(p, item); playAnimation(p, b, hand); } @@ -208,8 +204,7 @@ public class ClimbingPick extends SimpleSlimefunItem implements if (version.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) { if (hand == EquipmentSlot.HAND) { p.swingMainHand(); - } - else { + } else { p.swingOffHand(); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java index c61c67a5f..f9c9a78dc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/ExplosiveTool.java @@ -75,8 +75,7 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla } } } - } - else { + } else { for (Block block : blocks) { if (canBreak(p, block)) { breakBlock(p, item, block, fortune, drops); @@ -112,14 +111,11 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla protected boolean canBreak(Player p, Block b) { if (b.isEmpty() || b.isLiquid()) { return false; - } - else if (MaterialCollections.getAllUnbreakableBlocks().contains(b.getType())) { + } else if (MaterialCollections.getAllUnbreakableBlocks().contains(b.getType())) { return false; - } - else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) { + } else if (!b.getWorld().getWorldBorder().isInside(b.getLocation())) { return false; - } - else { + } else { return SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK); } } @@ -136,11 +132,9 @@ class ExplosiveTool extends SimpleSlimefunItem implements NotPla if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) { drops.add(BlockStorage.retrieve(b)); } - } - else if (b.getType() == Material.PLAYER_HEAD || b.getType() == Material.SHULKER_BOX || b.getType().name().endsWith("_SHULKER_BOX")) { + } else if (b.getType() == Material.PLAYER_HEAD || b.getType() == Material.SHULKER_BOX || b.getType().name().endsWith("_SHULKER_BOX")) { b.breakNaturally(item); - } - else { + } else { boolean applyFortune = b.getType().name().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE; for (ItemStack drop : b.getDrops(getItem())) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java index cb633e9d3..f60e49333 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/HerculesPickaxe.java @@ -23,11 +23,9 @@ public class HerculesPickaxe extends SimpleSlimefunItem { if (e.getBlock().getType().toString().endsWith("_ORE")) { if (e.getBlock().getType() == Material.IRON_ORE) { drops.add(new CustomItem(SlimefunItems.IRON_DUST, 2)); - } - else if (e.getBlock().getType() == Material.GOLD_ORE) { + } else if (e.getBlock().getType() == Material.GOLD_ORE) { drops.add(new CustomItem(SlimefunItems.GOLD_DUST, 2)); - } - else { + } else { for (ItemStack drop : e.getBlock().getDrops(tool)) { drops.add(new CustomItem(drop, drop.getAmount() * 2)); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java index 82ae021d1..0a997995f 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfTheSeeker.java @@ -31,8 +31,7 @@ public class PickaxeOfTheSeeker extends SimpleSlimefunItem imple if (closest == null) { SlimefunPlugin.getLocalization().sendMessage(p, "miner.no-ores"); - } - else { + } else { double l = closest.getX() + 0.5 - p.getLocation().getX(); double w = closest.getZ() + 0.5 - p.getLocation().getZ(); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java index 65cfbb203..7f42d70c6 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/PickaxeOfVeinMining.java @@ -61,11 +61,10 @@ public class PickaxeOfVeinMining extends SimpleSlimefunItem { for (Block b : blocks) { if (SlimefunPlugin.getProtectionManager().hasPermission(p, b.getLocation(), ProtectableAction.BREAK_BLOCK)) { b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType()); - + if (tool.containsEnchantment(Enchantment.SILK_TOUCH)) { b.getWorld().dropItemNaturally(b.getLocation(), new ItemStack(b.getType())); - } - else { + } else { for (ItemStack drop : b.getDrops(tool)) { b.getWorld().dropItemNaturally(b.getLocation(), drop.getType().isBlock() ? drop : new CustomItem(drop, fortune)); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java index d4a6bb326..ff1ce7a98 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/tools/TapeMeasure.java @@ -52,8 +52,7 @@ public class TapeMeasure extends SimpleSlimefunItem implements N if (e.getPlayer().isSneaking()) { setAnchor(e.getPlayer(), e.getItem(), block); - } - else { + } else { measure(e.getPlayer(), e.getItem(), block); } } @@ -96,13 +95,11 @@ public class TapeMeasure extends SimpleSlimefunItem implements N int z = json.get("z").getAsInt(); Location loc = new Location(p.getWorld(), x, y, z); return Optional.of(loc); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.wrong-world"); return Optional.empty(); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.tape-measure.no-anchor"); return Optional.empty(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java index cd4affd3e..905e0ce24 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/items/weapons/SwordOfBeheading.java @@ -43,23 +43,19 @@ public class SwordOfBeheading extends SimpleSlimefunItem { if (random.nextInt(100) < chanceZombie.getValue()) { e.getDrops().add(new ItemStack(Material.ZOMBIE_HEAD)); } - } - else if (e.getEntity() instanceof WitherSkeleton) { + } else if (e.getEntity() instanceof WitherSkeleton) { if (random.nextInt(100) < chanceWitherSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.WITHER_SKELETON_SKULL)); } - } - else if (e.getEntity() instanceof Skeleton) { + } else if (e.getEntity() instanceof Skeleton) { if (random.nextInt(100) < chanceSkeleton.getValue()) { e.getDrops().add(new ItemStack(Material.SKELETON_SKULL)); } - } - else if (e.getEntity() instanceof Creeper) { + } else if (e.getEntity() instanceof Creeper) { if (random.nextInt(100) < chanceCreeper.getValue()) { e.getDrops().add(new ItemStack(Material.CREEPER_HEAD)); } - } - else if (e.getEntity() instanceof Player && random.nextInt(100) < chancePlayer.getValue()) { + } else if (e.getEntity() instanceof Player && random.nextInt(100) < chancePlayer.getValue()) { ItemStack skull = new ItemStack(Material.PLAYER_HEAD); ItemMeta meta = skull.getItemMeta(); ((SkullMeta) meta).setOwningPlayer((Player) e.getEntity()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java index 2c550defe..db808b7b4 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/AncientAltarListener.java @@ -109,8 +109,7 @@ public class AncientAltarListener implements Listener { if (id.equals(pedestalItem.getID())) { e.cancel(); usePedestal(b, e.getPlayer()); - } - else if (id.equals(altarItem.getID())) { + } else if (id.equals(altarItem.getID())) { if (!Slimefun.hasUnlocked(e.getPlayer(), altarItem, true) || altarsInUse.contains(b.getLocation())) { e.cancel(); return; @@ -149,8 +148,7 @@ public class AncientAltarListener implements Listener { // place the item onto the pedestal pedestalItem.placeItem(p, pedestal); } - } - else if (!removedItems.contains(stack.get().getUniqueId())) { + } else if (!removedItems.contains(stack.get().getUniqueId())) { Item entity = stack.get(); UUID uuid = entity.getUniqueId(); removedItems.add(uuid); @@ -180,8 +178,7 @@ public class AncientAltarListener implements Listener { if (catalyst.getType() != Material.AIR) { startRitual(p, altar, pedestals, catalyst); - } - else { + } else { altars.remove(altar); SlimefunPlugin.getLocalization().sendMessage(p, "machines.ANCIENT_ALTAR.unknown-catalyst", true); @@ -192,8 +189,7 @@ public class AncientAltarListener implements Listener { // Unknown catalyst, no longer in use altarsInUse.remove(altar.getLocation()); } - } - else { + } else { altars.remove(altar); SlimefunPlugin.getLocalization().sendMessage(p, "machines.ANCIENT_ALTAR.not-enough-pedestals", true, msg -> msg.replace("%pedestals%", String.valueOf(pedestals.size()))); @@ -229,8 +225,7 @@ public class AncientAltarListener implements Listener { AncientAltarTask task = new AncientAltarTask(this, b, altarItem.getSpeed(), result.get(), pedestals, consumed, p); SlimefunPlugin.runSync(task, 10L); - } - else { + } else { altars.remove(b); for (Block block : pedestals) { @@ -240,8 +235,7 @@ public class AncientAltarListener implements Listener { // Item not unlocked, no longer in use. altarsInUse.remove(b.getLocation()); } - } - else { + } else { altars.remove(b); SlimefunPlugin.getLocalization().sendMessage(p, "machines.ANCIENT_ALTAR.unknown-recipe", true); @@ -350,8 +344,7 @@ public class AncientAltarListener implements Listener { for (int j = 1; j < 8; j++) { if (!SlimefunUtils.isItemSimilar(items.get((i + j) % items.size()), recipe.getInput().get(j), true)) { break; - } - else if (j == 7) { + } else if (j == 7) { return Optional.of(recipe.getOutput()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java index d971cfdef..ddbcaa8fc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BackpackListener.java @@ -94,8 +94,7 @@ public class BackpackListener implements Listener { e.setCancelled(true); } } - } - else if (!isAllowed((SlimefunBackpack) backpack, e.getCurrentItem())) { + } else if (!isAllowed((SlimefunBackpack) backpack, e.getCurrentItem())) { e.setCancelled(true); } } @@ -115,8 +114,7 @@ public class BackpackListener implements Listener { if (Slimefun.hasUnlocked(p, backpack, true) && !PlayerProfile.get(p, profile -> openBackpack(p, item, profile, backpack.getSize()))) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.opening-backpack"); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "backpack.no-stack", true); } } @@ -139,8 +137,7 @@ public class BackpackListener implements Listener { backpack.open(p); } }); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "backpack.already-open", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java index 2089e28b2..28f037681 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockListener.java @@ -76,8 +76,7 @@ public class BlockListener implements Listener { if (sfItem != null && Slimefun.isEnabled(e.getPlayer(), sfItem, true) && !(sfItem instanceof NotPlaceable)) { if (!Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) { e.setCancelled(true); - } - else { + } else { if (SlimefunPlugin.getBlockDataService().isTileEntity(e.getBlock().getType())) { SlimefunPlugin.getBlockDataService().setBlockData(e.getBlock(), sfItem.getID()); } @@ -113,8 +112,7 @@ public class BlockListener implements Listener { if (tool != null) { if (Slimefun.hasUnlocked(e.getPlayer(), tool, true)) { tool.callItemHandler(ToolUseHandler.class, handler -> handler.onToolUse(e, item, fortune, drops)); - } - else { + } else { e.setCancelled(true); } } @@ -139,8 +137,7 @@ public class BlockListener implements Listener { e.setCancelled(true); return; } - } - else { + } else { sfItem.callItemHandler(BlockBreakHandler.class, handler -> handler.onBlockBreak(e, item, fortune, drops)); } @@ -189,8 +186,7 @@ public class BlockListener implements Listener { blockAbove.getWorld().dropItemNaturally(blockAbove.getLocation(), BlockStorage.retrieve(blockAbove)); blockAbove.setType(Material.AIR); } - } - else { + } else { blockAbove.getWorld().dropItemNaturally(blockAbove.getLocation(), BlockStorage.retrieve(blockAbove)); blockAbove.setType(Material.AIR); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java index 29f421ed6..b6d6d2c1a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/BlockPhysicsListener.java @@ -57,8 +57,7 @@ public class BlockPhysicsListener implements Listener { public void onPistonExtend(BlockPistonExtendEvent e) { if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); - } - else { + } else { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); @@ -72,8 +71,7 @@ public class BlockPhysicsListener implements Listener { public void onPistonRetract(BlockPistonRetractEvent e) { if (BlockStorage.hasBlockInfo(e.getBlock())) { e.setCancelled(true); - } - else if (e.isSticky()) { + } else if (e.isSticky()) { for (Block b : e.getBlocks()) { if (BlockStorage.hasBlockInfo(b) || (b.getRelative(e.getDirection()).getType() == Material.AIR && BlockStorage.hasBlockInfo(b.getRelative(e.getDirection())))) { e.setCancelled(true); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java index 9f1528d04..67ca488cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CargoNodeListener.java @@ -38,19 +38,15 @@ public class CargoNodeListener implements Listener { if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) { ItemStackWrapper wrapper = new ItemStackWrapper(item); - return SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_INPUT_NODE, false) - || SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_OUTPUT_NODE, false) - || SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_OUTPUT_NODE_2, false); + return SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_INPUT_NODE, false) || SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_OUTPUT_NODE, false) || SlimefunUtils.isItemSimilar(wrapper, SlimefunItems.CARGO_OUTPUT_NODE_2, false); } - + SlimefunItem sfItem = SlimefunItem.getByItem(item); - + if (sfItem == null) { return false; } - - return sfItem.getID().equals(SlimefunItems.CARGO_INPUT_NODE.getItemId()) - || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE.getItemId()) - || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE_2.getItemId()); + + return sfItem.getID().equals(SlimefunItems.CARGO_INPUT_NODE.getItemId()) || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE.getItemId()) || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE_2.getItemId()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java index 7794dd071..c54f501d2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/CoolerListener.java @@ -74,8 +74,7 @@ public class CoolerListener implements Listener { if (cooler.isItem(item)) { if (Slimefun.hasUnlocked(p, cooler, true)) { takeJuiceFromCooler(p, item); - } - else { + } else { return; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java index e084cb084..1a4fd5b5b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/DebugFishListener.java @@ -63,12 +63,10 @@ public class DebugFishListener implements Listener { if (p.hasPermission("slimefun.debugging")) { if (e.getAction() == Action.LEFT_CLICK_BLOCK) { onLeftClick(p, e.getClickedBlock(), e); - } - else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { + } else if (e.getAction() == Action.RIGHT_CLICK_BLOCK) { onRightClick(p, e.getClickedBlock(), e.getBlockFace()); } - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "messages.no-permission", true); } } @@ -80,8 +78,7 @@ public class DebugFishListener implements Listener { if (BlockStorage.hasBlockInfo(b)) { BlockStorage.clearBlockInfo(b); } - } - else { + } else { e.setCancelled(false); } } @@ -92,12 +89,10 @@ public class DebugFishListener implements Listener { Block block = b.getRelative(face); block.setType(Material.PLAYER_HEAD); SkullBlock.setFromHash(block, HeadTexture.MISSING_TEXTURE.getTexture()); - } - else if (BlockStorage.hasBlockInfo(b)) { + } else if (BlockStorage.hasBlockInfo(b)) { try { sendInfo(p, b); - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, "An Exception occurred while using a Debug-Fish", x); } } @@ -118,27 +113,23 @@ public class DebugFishListener implements Listener { // Check if the skull is a wall skull, and if so use Directional instead of Rotatable. if (b.getType() == Material.PLAYER_WALL_HEAD) { p.sendMessage(ChatColors.color(" &dFacing: &e" + ((Directional) b.getBlockData()).getFacing().toString())); - } - else { + } else { p.sendMessage(ChatColors.color(" &dRotation: &e" + ((Rotatable) b.getBlockData()).getRotation().toString())); } } if (BlockStorage.getStorage(b.getWorld()).hasInventory(b.getLocation())) { p.sendMessage(ChatColors.color("&dInventory: " + greenCheckmark)); - } - else { + } else { p.sendMessage(ChatColors.color("&dInventory: " + redCross)); } if (item.isTicking()) { p.sendMessage(ChatColors.color("&dTicking: " + greenCheckmark)); p.sendMessage(ChatColors.color(" &dAsync: &e" + (item.getBlockTicker().isSynchronized() ? redCross : greenCheckmark))); - } - else if (item instanceof EnergyNetProvider) { + } else if (item instanceof EnergyNetProvider) { p.sendMessage(ChatColors.color("&dTicking: &3Indirect (Generator)")); - } - else { + } else { p.sendMessage(ChatColors.color("&dTicking: " + redCross)); } @@ -156,8 +147,7 @@ public class DebugFishListener implements Listener { if (component.isChargeable()) { p.sendMessage(ChatColors.color(" &dChargeable: " + greenCheckmark)); p.sendMessage(ChatColors.color(" &dEnergy: &e" + component.getCharge(b.getLocation()) + " / " + component.getCapacity())); - } - else { + } else { p.sendMessage(ChatColors.color("&dChargeable: " + redCross)); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java index d01992c45..ad5f25c6c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ElytraCrashListener.java @@ -1,30 +1,31 @@ package io.github.thebusybiscuit.slimefun4.implementation.listeners; -import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece; -import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; -import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; -import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor; -import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; -import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; -import me.mrCookieSlime.Slimefun.api.Slimefun; -import org.bukkit.GameMode; +import java.util.Optional; + +import javax.annotation.Nonnull; + import org.bukkit.Sound; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.inventory.ItemStack; +import org.bukkit.event.entity.EntityDamageEvent.DamageCause; -import javax.annotation.Nonnull; -import java.util.Arrays; -import java.util.Optional; +import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; +import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem; +import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType; +import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; +import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem; +import me.mrCookieSlime.Slimefun.api.Slimefun; /** * The {@link Listener} for the {@link ElytraCap}. * * @author Seggan + * + * @see ElytraCap */ public class ElytraCrashListener implements Listener { @@ -34,27 +35,35 @@ public class ElytraCrashListener implements Listener { @EventHandler public void onPlayerCrash(EntityDamageEvent e) { - if (!(e.getEntity() instanceof Player)) return; - if (!(e.getCause() == EntityDamageEvent.DamageCause.FALL || - e.getCause() == EntityDamageEvent.DamageCause.FLY_INTO_WALL)) return; + if (!(e.getEntity() instanceof Player)) { + // We only wanna handle damaged Players + return; + } - Player p = (Player) e.getEntity(); - if (p.isGliding()) { - Optional optional = PlayerProfile.find(p); - if (!optional.isPresent()) { - PlayerProfile.request(p); - return; - } - PlayerProfile profile = optional.get(); - HashedArmorpiece helmet = profile.getArmor()[0]; - if (helmet.getItem().isPresent()) { - SlimefunItem item = helmet.getItem().get(); - if (Slimefun.hasUnlocked(p, item, true) - && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { - e.setDamage(0); - p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); - if (p.getGameMode() != GameMode.CREATIVE && item instanceof DamageableItem) { - ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); + if (e.getCause() == DamageCause.FALL || e.getCause() == DamageCause.FLY_INTO_WALL) { + Player p = (Player) e.getEntity(); + + if (p.isGliding()) { + Optional optional = PlayerProfile.find(p); + + if (!optional.isPresent()) { + PlayerProfile.request(p); + return; + } + + PlayerProfile profile = optional.get(); + Optional helmet = profile.getArmor()[0].getItem(); + + if (helmet.isPresent()) { + SlimefunItem item = helmet.get(); + + if (Slimefun.hasUnlocked(p, item, true) && profile.hasFullProtectionAgainst(ProtectionType.FLYING_INTO_WALL)) { + e.setDamage(0); + p.playSound(p.getLocation(), Sound.BLOCK_STONE_HIT, 20, 1); + + if (item instanceof DamageableItem) { + ((DamageableItem) item).damageItem(p, p.getInventory().getHelmet()); + } } } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java index f8fcd8e86..2fd7ad0e9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/EntityInteractionListener.java @@ -39,8 +39,7 @@ public class EntityInteractionListener implements Listener { if (e.getHand() == EquipmentSlot.OFF_HAND) { itemStack = e.getPlayer().getInventory().getItemInOffHand(); - } - else { + } else { itemStack = e.getPlayer().getInventory().getItemInMainHand(); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java index 789dbc376..833cac81c 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GadgetsListener.java @@ -77,8 +77,7 @@ public class GadgetsListener implements Listener { if (thrust > 0.2) { new JetpackTask(p, (Jetpack) chestplate).scheduleRepeating(0, 3); } - } - else if (chestplate instanceof Parachute) { + } else if (chestplate instanceof Parachute) { new ParachuteTask(p).scheduleRepeating(0, 3); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java index 98b3d4668..761b2434d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/GrapplingHookListener.java @@ -171,8 +171,7 @@ public class GrapplingHookListener implements Listener { if (target.getY() <= p.getLocation().getY()) { velocity = target.toVector().subtract(p.getLocation().toVector()); } - } - else { + } else { Location l = p.getLocation(); l.setY(l.getY() + 0.5); p.teleport(l); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/IronGolemListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/IronGolemListener.java index 5429251fa..8bb6e4c2e 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/IronGolemListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/IronGolemListener.java @@ -38,8 +38,7 @@ public class IronGolemListener implements Listener { if (e.getHand() == EquipmentSlot.HAND) { item = inv.getItemInMainHand(); - } - else if (e.getHand() == EquipmentSlot.OFF_HAND) { + } else if (e.getHand() == EquipmentSlot.OFF_HAND) { item = inv.getItemInOffHand(); } @@ -54,8 +53,7 @@ public class IronGolemListener implements Listener { // Somehow cancelling it isn't enough. if (e.getHand() == EquipmentSlot.HAND) { inv.setItemInMainHand(item); - } - else if (e.getHand() == EquipmentSlot.OFF_HAND) { + } else if (e.getHand() == EquipmentSlot.OFF_HAND) { inv.setItemInOffHand(item); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java index dfe75b720..7dea7b47b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/ItemPickupListener.java @@ -27,8 +27,7 @@ public class ItemPickupListener implements Listener { public void onEntityPickup(EntityPickupItemEvent e) { if (SlimefunUtils.hasNoPickupFlag(e.getItem())) { e.setCancelled(true); - } - else if (e.getItem().getItemStack().hasItemMeta()) { + } else if (e.getItem().getItemStack().hasItemMeta()) { ItemMeta meta = e.getItem().getItemStack().getItemMeta(); if (meta.hasDisplayName() && meta.getDisplayName().startsWith(AncientPedestal.ITEM_PREFIX)) { @@ -42,8 +41,7 @@ public class ItemPickupListener implements Listener { public void onHopperPickup(InventoryPickupItemEvent e) { if (SlimefunUtils.hasNoPickupFlag(e.getItem())) { e.setCancelled(true); - } - else if (e.getItem().getItemStack().hasItemMeta()) { + } else if (e.getItem().getItemStack().hasItemMeta()) { ItemMeta meta = e.getItem().getItemStack().getItemMeta(); if (meta.hasDisplayName() && meta.getDisplayName().startsWith(AncientPedestal.ITEM_PREFIX)) { diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java index d3007e30a..bae497288 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/MobDropListener.java @@ -67,8 +67,7 @@ public class MobDropListener implements Listener { if (sfi == null) { return true; - } - else if (Slimefun.hasUnlocked(p, sfi, true)) { + } else if (Slimefun.hasUnlocked(p, sfi, true)) { if (sfi instanceof RandomMobDrop) { int random = ThreadLocalRandom.current().nextInt(100); @@ -82,8 +81,7 @@ public class MobDropListener implements Listener { } return true; - } - else { + } else { return false; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java index 4e191fc6f..2add2f695 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/PiglinListener.java @@ -60,8 +60,7 @@ public class PiglinListener implements Listener { if (e.getHand() == EquipmentSlot.OFF_HAND) { item = p.getInventory().getItemInOffHand(); - } - else { + } else { item = p.getInventory().getItemInMainHand(); } @@ -96,8 +95,7 @@ public class PiglinListener implements Listener { if (chance < 1 || chance >= 100) { sfi.warn("The Piglin Bartering chance must be between 1-99% on item: " + sfi.getID()); - } - else if (chance > ThreadLocalRandom.current().nextInt(100)) { + } else if (chance > ThreadLocalRandom.current().nextInt(100)) { e.getItemDrop().setItemStack(sfi.getRecipeOutput()); return; } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java index 3353e30a9..55c19435d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunBootsListener.java @@ -42,8 +42,7 @@ public class SlimefunBootsListener implements Listener { if (e.getEntity() instanceof Player) { if (e.getCause() == DamageCause.FALL) { onFallDamage(e); - } - else if (e instanceof EntityDamageByEntityEvent) { + } else if (e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; if (event.getDamager() instanceof EnderPearl) { @@ -66,8 +65,7 @@ public class SlimefunBootsListener implements Listener { if (boots instanceof StomperBoots) { e.setCancelled(true); ((StomperBoots) boots).stomp(e); - } - else if (boots.getID().equals("SLIME_BOOTS") || boots.getID().equals("SLIME_STEEL_BOOTS")) { + } else if (boots.getID().equals("SLIME_BOOTS") || boots.getID().equals("SLIME_STEEL_BOOTS")) { e.setCancelled(true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java index e463df537..5575ce2aa 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunGuideListener.java @@ -50,48 +50,43 @@ public class SlimefunGuideListener implements Listener { if (tryOpenGuide(p, e, SlimefunGuideLayout.BOOK) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); - } - else { + } else { openGuide(p, e, SlimefunGuideLayout.BOOK); } - } - else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { + } else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEST) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); - } - else { + } else { openGuide(p, e, SlimefunGuideLayout.CHEST); } - } - else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { + } else if (tryOpenGuide(p, e, SlimefunGuideLayout.CHEAT_SHEET) == Result.ALLOW) { if (p.isSneaking()) { SlimefunGuideSettings.openSettings(p, e.getItem()); - } - else { + } else { // We rather just run the command here, // all necessary permission checks will be handled there. p.chat("/sf cheat"); } } } - + @ParametersAreNonnullByDefault private void openGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { SlimefunGuideOpenEvent event = new SlimefunGuideOpenEvent(p, e.getItem(), layout); Bukkit.getPluginManager().callEvent(event); - + if (!event.isCancelled()) { e.cancel(); SlimefunGuide.openGuide(p, event.getGuideLayout()); - } - } + } + } @Nonnull @ParametersAreNonnullByDefault private Result tryOpenGuide(Player p, PlayerRightClickEvent e, SlimefunGuideLayout layout) { ItemStack item = e.getItem(); if (SlimefunUtils.isItemSimilar(item, SlimefunGuide.getItem(layout), true, false)) { - + if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-item", true); return Result.DENY; diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java index c671f44c8..bfd4d657a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemConsumeListener.java @@ -35,8 +35,7 @@ public class SlimefunItemConsumeListener implements Listener { if (sfItem != null) { if (Slimefun.hasUnlocked(p, sfItem, true)) { sfItem.callItemHandler(ItemConsumptionHandler.class, handler -> handler.onConsume(e, p, item)); - } - else { + } else { e.setCancelled(true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java index 9102a433e..2b54a4cd2 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/SlimefunItemListener.java @@ -75,8 +75,7 @@ public class SlimefunItemListener implements Listener { if (optional.isPresent()) { if (Slimefun.hasUnlocked(e.getPlayer(), optional.get(), true)) { return optional.get().callItemHandler(ItemUseHandler.class, handler -> handler.onRightClick(event)); - } - else { + } else { event.setUseItem(Result.DENY); } } @@ -120,18 +119,15 @@ public class SlimefunItemListener implements Listener { if (menu.canOpen(e.getClickedBlock(), p)) { menu.open(p); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); } - } - else if (BlockStorage.getStorage(e.getClickedBlock().getWorld()).hasInventory(e.getClickedBlock().getLocation())) { + } else if (BlockStorage.getStorage(e.getClickedBlock().getWorld()).hasInventory(e.getClickedBlock().getLocation())) { BlockMenu menu = BlockStorage.getInventory(e.getClickedBlock().getLocation()); if (menu.canOpen(e.getClickedBlock(), p)) { menu.open(p); - } - else { + } else { SlimefunPlugin.getLocalization().sendMessage(p, "inventory.no-access", true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java index a8da01485..d70650b09 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TalismanListener.java @@ -348,8 +348,7 @@ public class TalismanListener implements Listener { amount = Math.max(amount, 1); amount = (type == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (amount + 1); return amount; - } - else { + } else { return 1; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java index 417a42bca..3d646ae49 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/TeleporterListener.java @@ -47,8 +47,7 @@ public class TeleporterListener implements Listener { UUID owner = UUID.fromString(BlockStorage.getLocationInfo(block.getLocation(), "owner")); SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI(e.getPlayer(), owner, block, SlimefunPlugin.getGPSNetwork().getNetworkComplexity(owner)); } - } - else if (id.equals(SlimefunItems.ELEVATOR_PLATE.getItemId())) { + } else if (id.equals(SlimefunItems.ELEVATOR_PLATE.getItemId())) { ElevatorPlate elevator = ((ElevatorPlate) SlimefunItems.ELEVATOR_PLATE.getItem()); elevator.openInterface(e.getPlayer(), e.getClickedBlock()); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VampireBladeListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VampireBladeListener.java index 877832c8f..6cef24bd9 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VampireBladeListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VampireBladeListener.java @@ -46,8 +46,7 @@ public class VampireBladeListener implements Listener { if (blade.isItem(p.getInventory().getItemInMainHand())) { if (Slimefun.hasUnlocked(p, blade, true)) { blade.heal(p); - } - else { + } else { e.setCancelled(true); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java index b517efb0b..e4e5b49ee 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VanillaMachinesListener.java @@ -102,7 +102,7 @@ public class VanillaMachinesListener implements Listener { if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) { return; } - + if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) { ItemStack item1 = e.getInventory().getContents()[0]; ItemStack item2 = e.getInventory().getContents()[1]; @@ -127,8 +127,7 @@ public class VanillaMachinesListener implements Listener { if (clickedInventory.getType() == InventoryType.BREWING) { e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor()))); - } - else { + } else { e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCurrentItem()))); } @@ -141,8 +140,7 @@ public class VanillaMachinesListener implements Listener { private boolean checkForUnallowedItems(@Nullable ItemStack item1, @Nullable ItemStack item2) { if (SlimefunGuide.isGuideItem(item1) || SlimefunGuide.isGuideItem(item2)) { return true; - } - else { + } else { SlimefunItem sfItem1 = SlimefunItem.getByItem(item1); SlimefunItem sfItem2 = SlimefunItem.getByItem(item2); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java index 8a95420e5..f25ca6992 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/VillagerTradingListener.java @@ -43,8 +43,7 @@ public class VillagerTradingListener implements Listener { if (clickedInventory.getType() == InventoryType.MERCHANT) { e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor()))); - } - else { + } else { e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCurrentItem()))); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java index 0e4ffecec..a18400451 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/listeners/WorldListener.java @@ -31,8 +31,7 @@ public class WorldListener implements Listener { if (storage != null) { storage.saveAndRemove(); - } - else { + } else { Slimefun.getLogger().log(Level.SEVERE, "Could not save Slimefun Blocks for World \"{0}\"", e.getWorld().getName()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java index c90bc6e43..bb2363e03 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/DefaultCategories.java @@ -52,7 +52,7 @@ class DefaultCategories { // Locked Categories protected final LockedCategory electricity = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "electricity"), new CustomItem(SlimefunItems.NUCLEAR_REACTOR, "&bEnergy and Electricity"), 4, basicMachines.getKey()); - protected final LockedCategory androids = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "androids"), new CustomItem(SlimefunItems.PROGRAMMABLE_ANDROID, "&cProgrammable Androids"), 4, basicMachines.getKey()); + protected final LockedCategory androids = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "androids"), new CustomItem(SlimefunItems.PROGRAMMABLE_ANDROID, "&cProgrammable Androids"), 4, basicMachines.getKey()); protected final Category cargo = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "cargo"), new CustomItem(SlimefunItems.CARGO_MANAGER, "&cCargo Management"), 4, basicMachines.getKey()); protected final LockedCategory gps = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "gps"), new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS-based Machines"), 4, basicMachines.getKey()); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java index 4d6ebd3c5..fde4d756d 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/PostSetup.java @@ -14,6 +14,8 @@ import java.util.logging.Level; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.annotation.Nonnull; + import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -59,8 +61,7 @@ public final class PostSetup { item.addOficialWikipage(entry.getValue().getAsString()); } } - } - catch (IOException e) { + } catch (IOException e) { Slimefun.getLogger().log(Level.SEVERE, "Failed to load wiki.json file", e); } } @@ -74,8 +75,7 @@ public final class PostSetup { if (item == null) { Slimefun.getLogger().log(Level.WARNING, "Removed bugged Item ('NULL?')"); iterator.remove(); - } - else { + } else { item.load(); } } @@ -105,8 +105,7 @@ public final class PostSetup { sender.sendMessage(ChatColor.GREEN + " - Addons: https://github.com/Slimefun/Slimefun4/wiki/Addons"); sender.sendMessage(ChatColor.GREEN + " - Bug Reports: https://github.com/Slimefun/Slimefun4/issues"); sender.sendMessage(ChatColor.GREEN + " - Discord: https://discord.gg/slimefun"); - } - else { + } else { sender.sendMessage(ChatColor.GREEN + " - UNOFFICIALLY MODIFIED BUILD - NO OFFICIAL SUPPORT GIVEN"); } @@ -157,8 +156,7 @@ public final class PostSetup { for (ItemStack[] recipe : grinder.getRecipes()) { if (input == null) { input = recipe; - } - else { + } else { if (input[0] != null && recipe[0] != null) { grinderRecipes.add(new ItemStack[] { input[0], recipe[0] }); } @@ -175,8 +173,7 @@ public final class PostSetup { for (ItemStack[] recipe : crusher.getRecipes()) { if (input == null) { input = recipe; - } - else { + } else { if (input[0] != null && recipe[0] != null) { grinderRecipes.add(new ItemStack[] { input[0], recipe[0] }); } @@ -206,8 +203,7 @@ public final class PostSetup { for (ItemStack[] output : smeltery.getRecipes()) { if (input == null) { input = output; - } - else { + } else { if (input[0] != null && output[0] != null) { addSmelteryRecipe(input, output, makeshiftSmeltery); } @@ -245,13 +241,12 @@ public final class PostSetup { registerMachineRecipe("ELECTRIC_INGOT_FACTORY", 8, new ItemStack[] { ingredients.get(0) }, new ItemStack[] { output[0] }); registerMachineRecipe("ELECTRIC_INGOT_PULVERIZER", 3, new ItemStack[] { output[0] }, new ItemStack[] { ingredients.get(0) }); - } - else { + } else { registerMachineRecipe("ELECTRIC_SMELTERY", 12, ingredients.toArray(new ItemStack[0]), new ItemStack[] { output[0] }); } } - private static boolean isDust(ItemStack item) { + private static boolean isDust(@Nonnull ItemStack item) { SlimefunItem sfItem = SlimefunItem.getByItem(item); return sfItem != null && sfItem.getID().endsWith("_DUST"); } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java index e282f7532..4117b2405 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/ResearchSetup.java @@ -1,5 +1,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.setup; +import javax.annotation.ParametersAreNonnullByDefault; + import org.bukkit.Material; import org.bukkit.NamespacedKey; import org.bukkit.inventory.ItemStack; @@ -281,6 +283,7 @@ public final class ResearchSetup { register("resurrected_talisman", 270, "Talisman of the Resurrected", 20, SlimefunItems.TALISMAN_RESURRECTED); } + @ParametersAreNonnullByDefault private static void register(String key, int id, String name, int defaultCost, ItemStack... items) { Research research = new Research(new NamespacedKey(SlimefunPlugin.instance(), key), id, name, defaultCost); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java index 531aa1547..a6e76ee22 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/setup/SlimefunItemSetup.java @@ -34,12 +34,12 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FisherAn import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ProgrammableAndroid; import io.github.thebusybiscuit.slimefun4.implementation.items.androids.WoodcutterAndroid; +import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.FarmerShoes; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.HazmatArmorPiece; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.Parachute; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece; import io.github.thebusybiscuit.slimefun4.implementation.items.armor.StomperBoots; -import io.github.thebusybiscuit.slimefun4.implementation.items.armor.ElytraCap; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.Cooler; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.EnderBackpack; import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack; @@ -134,11 +134,11 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.magical.Knowledge import io.github.thebusybiscuit.slimefun4.implementation.items.magical.KnowledgeTome; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicEyeOfEnder; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.MagicalZombiePills; -import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.StormStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.TelepositionScroll; +import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WaterStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.WindStaff; import io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans.MagicianTalisman; @@ -219,8 +219,7 @@ public final class SlimefunItemSetup { YELLOW_DYE = Material.YELLOW_DYE; BLACK_DYE = Material.BLACK_DYE; GREEN_DYE = Material.GREEN_DYE; - } - else { + } else { RED_DYE = Material.valueOf("ROSE_RED"); YELLOW_DYE = Material.valueOf("DANDELION_YELLOW"); BLACK_DYE = Material.valueOf("INK_SAC"); @@ -1128,10 +1127,6 @@ public final class SlimefunItemSetup { new ItemStack[] {SlimefunItems.NICKEL_INGOT, SlimefunItems.ALUMINUM_DUST, SlimefunItems.IRON_DUST, SlimefunItems.COBALT_INGOT, null, null, null, null, null}) .register(plugin); - new ElytraCap(categories.magicalGadgets, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, - new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) - .register(plugin); - new InfusedMagnet(categories.magicalGadgets, SlimefunItems.INFUSED_MAGNET, RecipeType.MAGIC_WORKBENCH, new ItemStack[] {SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.ENDER_LUMP_2, SlimefunItems.MAGNET, SlimefunItems.ENDER_LUMP_2, SlimefunItems.MAGIC_LUMP_3, null, SlimefunItems.MAGIC_LUMP_3}) .register(plugin); @@ -3088,6 +3083,10 @@ public final class SlimefunItemSetup { new SlimefunItemStack(SlimefunItems.VILLAGER_RUNE, 3)) .register(plugin); } + + new ElytraCap(categories.magicalArmor, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE, + new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)}) + .register(plugin); } private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) { @@ -3102,11 +3101,9 @@ public final class SlimefunItemSetup { for (int i = 0; i < 4; i++) { if (vanilla) { new VanillaItem(category, items[i], idSyntax + components[i], RecipeType.ARMOR_FORGE, recipes.get(i)).register(addon); - } - else if (i < effects.length && effects[i].length > 0) { + } else if (i < effects.length && effects[i].length > 0) { new SlimefunArmorPiece(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i), effects[i]).register(addon); - } - else { + } else { new SlimefunItem(category, new SlimefunItemStack(idSyntax + components[i], items[i]), RecipeType.ARMOR_FORGE, recipes.get(i)).register(addon); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java index a6fd8bdeb..3cb89b6da 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/AncientAltarTask.java @@ -130,8 +130,7 @@ public class AncientAltarTask implements Runnable { if (!item.isPresent() || positionLock.remove(item.get()) == null) { abort(); - } - else { + } else { Item entity = item.get(); particleLocations.add(pedestal.getLocation().add(0.5, 1.5, 0.5)); items.add(pedestalItem.getOriginalItemStack(entity)); @@ -179,8 +178,7 @@ public class AncientAltarTask implements Runnable { // This should re-enable altar blocks on craft completion. listener.getAltarsInUse().remove(altar.getLocation()); listener.getAltars().remove(altar); - } - else { + } else { dropLocation.getWorld().playSound(dropLocation, Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 1F); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetBootsTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetBootsTask.java index 1796150da..5946d5f8a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetBootsTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetBootsTask.java @@ -42,8 +42,7 @@ public class JetBootsTask extends PlayerTask { Vector vector = new Vector(p.getEyeLocation().getDirection().getX() * boots.getSpeed() + offset, gravity, p.getEyeLocation().getDirection().getZ() * boots.getSpeed() - offset); p.setVelocity(vector); - } - else { + } else { Bukkit.getScheduler().cancelTask(id); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetpackTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetpackTask.java index 8a31be635..cc0bac58a 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetpackTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/JetpackTask.java @@ -42,8 +42,7 @@ public class JetpackTask extends PlayerTask { vector.add(p.getEyeLocation().getDirection().multiply(0.2F)); p.setVelocity(vector); - } - else { + } else { Bukkit.getScheduler().cancelTask(id); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java index 5731622f1..4b273a842 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/SlimefunStartupTask.java @@ -55,8 +55,7 @@ public class SlimefunStartupTask implements Runnable { for (World world : Bukkit.getWorlds()) { try { new BlockStorage(world); - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while trying to load World \"" + world.getName() + "\" for Slimefun v" + SlimefunPlugin.getVersion()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java index ba3856383..af2e747e5 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/tasks/TickerTask.java @@ -112,8 +112,7 @@ public class TickerTask implements Runnable { reset(); SlimefunPlugin.getProfiler().stop(); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception was caught while ticking the Block Tickers Task for Slimefun v" + SlimefunPlugin.getVersion()); reset(); } @@ -133,8 +132,7 @@ public class TickerTask implements Runnable { tickLocation(tickers, l); } } - } - catch (ArrayIndexOutOfBoundsException | NumberFormatException x) { + } catch (ArrayIndexOutOfBoundsException | NumberFormatException x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception has occurred while trying to parse Chunk: " + chunk); } } @@ -154,8 +152,7 @@ public class TickerTask implements Runnable { Block b = l.getBlock(); tickBlock(l, b, item, data, System.nanoTime()); }); - } - else { + } else { long timestamp = SlimefunPlugin.getProfiler().newEntry(); item.getBlockTicker().update(); Block b = l.getBlock(); @@ -163,8 +160,7 @@ public class TickerTask implements Runnable { } tickers.add(item.getBlockTicker()); - } - catch (Exception x) { + } catch (Exception x) { reportErrors(l, item, x); } } @@ -174,11 +170,9 @@ public class TickerTask implements Runnable { private void tickBlock(Location l, Block b, SlimefunItem item, Config data, long timestamp) { try { item.getBlockTicker().tick(b, item, data); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { reportErrors(l, item, x); - } - finally { + } finally { SlimefunPlugin.getProfiler().closeEntry(l, item, timestamp); } } @@ -192,8 +186,7 @@ public class TickerTask implements Runnable { // Generate a new Error-Report new ErrorReport<>(x, l, item); bugs.put(position, errors); - } - else if (errors == 4) { + } else if (errors == 4) { Slimefun.getLogger().log(Level.SEVERE, "X: {0} Y: {1} Z: {2} ({3})", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ(), item.getID() }); Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 error messages in the last 4 Ticks, the Block has been terminated."); Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details."); @@ -202,8 +195,7 @@ public class TickerTask implements Runnable { BlockStorage.deleteLocationInfoUnsafely(l, true); Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance(), () -> l.getBlock().setType(Material.AIR)); - } - else { + } else { bugs.put(position, errors); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java index a820f0fac..fe1f75b28 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChatUtils.java @@ -39,8 +39,7 @@ public final class ChatUtils { public static String crop(@Nonnull ChatColor color, @Nonnull String string) { if (ChatColor.stripColor(color + string).length() > 19) { return (color + ChatColor.stripColor(string)).substring(0, 18) + "..."; - } - else { + } else { return color + ChatColor.stripColor(string); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java index f37c7db44..7f566db35 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/ChestMenuUtils.java @@ -94,8 +94,7 @@ public final class ChestMenuUtils { meta.setDisplayName(ChatColor.DARK_GRAY + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.pages.previous")); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); }); - } - else { + } else { return new CustomItem(PREV_BUTTON_ACTIVE, meta -> { meta.setDisplayName(ChatColor.WHITE + "\u21E6 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.pages.previous")); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); @@ -110,8 +109,7 @@ public final class ChestMenuUtils { meta.setDisplayName(ChatColor.DARK_GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.pages.next") + " \u21E8"); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); }); - } - else { + } else { return new CustomItem(NEXT_BUTTON_ACTIVE, meta -> { meta.setDisplayName(ChatColor.WHITE + SlimefunPlugin.getLocalization().getMessage(p, "guide.pages.next") + " \u21E8"); meta.setLore(Arrays.asList("", ChatColor.GRAY + "(" + page + " / " + pages + ")")); diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java index 8619d583e..445937f94 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/NumberUtils.java @@ -28,12 +28,18 @@ public final class NumberUtils { } public static ChatColor getColorFromPercentage(float percentage) { - if (percentage < 16.0F) return ChatColor.DARK_RED; - else if (percentage < 32.0F) return ChatColor.RED; - else if (percentage < 48.0F) return ChatColor.GOLD; - else if (percentage < 64.0F) return ChatColor.YELLOW; - else if (percentage < 80.0F) return ChatColor.DARK_GREEN; - else return ChatColor.GREEN; + if (percentage < 16.0F) + return ChatColor.DARK_RED; + else if (percentage < 32.0F) + return ChatColor.RED; + else if (percentage < 48.0F) + return ChatColor.GOLD; + else if (percentage < 64.0F) + return ChatColor.YELLOW; + else if (percentage < 80.0F) + return ChatColor.DARK_GREEN; + else + return ChatColor.GREEN; } public static String getElapsedTime(@Nonnull LocalDateTime date) { @@ -42,14 +48,11 @@ public final class NumberUtils { if (hours == 0) { return "< 1h"; - } - else if ((hours / 24) == 0) { + } else if ((hours / 24) == 0) { return (hours % 24) + "h"; - } - else if (hours % 24 == 0) { + } else if (hours % 24 == 0) { return (hours / 24) + "d"; - } - else { + } else { return (hours / 24) + "d " + (hours % 24) + "h"; } } @@ -84,8 +87,7 @@ public final class NumberUtils { if (parts.length == 1) { return parts[0] + "ms"; - } - else { + } else { return parts[0] + '.' + parts[1] + "ms"; } } @@ -120,11 +122,9 @@ public final class NumberUtils { public static int clamp(int min, int value, int max) { if (value < min) { return min; - } - else if (value > max) { + } else if (value > max) { return max; - } - else { + } else { return value; } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java index d8ed4e0db..19936524b 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/SlimefunUtils.java @@ -92,8 +92,7 @@ public final class SlimefunUtils { public static boolean isSoulbound(@Nullable ItemStack item) { if (item == null || item.getType() == Material.AIR) { return false; - } - else { + } else { ItemMeta meta = item.hasItemMeta() ? item.getItemMeta() : null; if (hasSoulboundFlag(meta)) { @@ -113,8 +112,7 @@ public final class SlimefunUtils { if (sfItem instanceof Soulbound) { return !sfItem.isDisabled(); - } - else if (meta != null) { + } else if (meta != null) { return meta.hasLore() && meta.getLore().contains(SOULBOUND_LORE); } @@ -252,10 +250,14 @@ public final class SlimefunUtils { } public static boolean isItemSimilar(@Nullable ItemStack item, @Nullable ItemStack sfitem, boolean checkLore, boolean checkAmount) { - if (item == null) return sfitem == null; - if (sfitem == null) return false; - if (item.getType() != sfitem.getType()) return false; - if (checkAmount && item.getAmount() < sfitem.getAmount()) return false; + if (item == null) + return sfitem == null; + if (sfitem == null) + return false; + if (item.getType() != sfitem.getType()) + return false; + if (checkAmount && item.getAmount() < sfitem.getAmount()) + return false; if (sfitem instanceof SlimefunItemStack && item instanceof SlimefunItemStack) { return ((SlimefunItemStack) item).getItemId().equals(((SlimefunItemStack) sfitem).getItemId()); @@ -273,12 +275,10 @@ public final class SlimefunUtils { ImmutableItemMeta meta = ((SlimefunItemStack) sfitem).getImmutableMeta(); return equalsItemMeta(itemMeta, meta, checkLore); - } - else if (sfitem.hasItemMeta()) { + } else if (sfitem.hasItemMeta()) { return equalsItemMeta(itemMeta, sfitem.getItemMeta(), checkLore); } - } - else { + } else { return !sfitem.hasItemMeta(); } @@ -290,20 +290,16 @@ public final class SlimefunUtils { if (itemMeta.hasDisplayName() != displayName.isPresent()) { return false; - } - else if (itemMeta.hasDisplayName() && displayName.isPresent() && !itemMeta.getDisplayName().equals(displayName.get())) { + } else if (itemMeta.hasDisplayName() && displayName.isPresent() && !itemMeta.getDisplayName().equals(displayName.get())) { return false; - } - else if (!checkLore) { + } else if (!checkLore) { return true; - } - else { + } else { Optional> itemLore = meta.getLore(); if (itemMeta.hasLore() && itemLore.isPresent()) { return equalsLore(itemMeta.getLore(), itemLore.get()); - } - else { + } else { return !itemMeta.hasLore() && !itemLore.isPresent(); } } @@ -312,17 +308,13 @@ public final class SlimefunUtils { private static boolean equalsItemMeta(@Nonnull ItemMeta itemMeta, @Nonnull ItemMeta sfitemMeta, boolean checkLore) { if (itemMeta.hasDisplayName() != sfitemMeta.hasDisplayName()) { return false; - } - else if (itemMeta.hasDisplayName() && sfitemMeta.hasDisplayName() && !itemMeta.getDisplayName().equals(sfitemMeta.getDisplayName())) { + } else if (itemMeta.hasDisplayName() && sfitemMeta.hasDisplayName() && !itemMeta.getDisplayName().equals(sfitemMeta.getDisplayName())) { return false; - } - else if (!checkLore) { + } else if (!checkLore) { return true; - } - else if (itemMeta.hasLore() && sfitemMeta.hasLore()) { + } else if (itemMeta.hasLore() && sfitemMeta.hasLore()) { return equalsLore(itemMeta.getLore(), sfitemMeta.getLore()); - } - else { + } else { return !itemMeta.hasLore() && !sfitemMeta.hasLore(); } } @@ -358,14 +350,11 @@ public final class SlimefunUtils { if (level <= 0.25) { SkullBlock.setFromHash(b, HeadTexture.CAPACITOR_25.getTexture()); - } - else if (level <= 0.5) { + } else if (level <= 0.5) { SkullBlock.setFromHash(b, HeadTexture.CAPACITOR_50.getTexture()); - } - else if (level <= 0.75) { + } else if (level <= 0.75) { SkullBlock.setFromHash(b, HeadTexture.CAPACITOR_75.getTexture()); - } - else { + } else { SkullBlock.setFromHash(b, HeadTexture.CAPACITOR_100.getTexture()); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java index 05419dbf4..f31fce8c1 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/holograms/SimpleHologram.java @@ -51,8 +51,7 @@ public final class SimpleHologram { if (!createIfNoneExists) { return null; - } - else { + } else { return create(l); } } diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java index 696d548ad..a910908ae 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/utils/itemstack/ItemStackWrapper.java @@ -37,8 +37,7 @@ public final class ItemStackWrapper extends ItemStack { if (hasItemMeta) { meta = item.getItemMeta(); - } - else { + } else { meta = null; } } @@ -56,8 +55,7 @@ public final class ItemStackWrapper extends ItemStack { // This will significantly speed up any loop comparisons if used correctly. if (meta == null) { throw new UnsupportedOperationException("This ItemStack has no ItemMeta! Make sure to check ItemStack#hasItemMeta() before accessing this method!"); - } - else { + } else { return meta; } } @@ -140,8 +138,7 @@ public final class ItemStackWrapper extends ItemStack { for (ItemStack item : items) { if (item != null) { list.add(new ItemStackWrapper(item)); - } - else { + } else { list.add(null); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java b/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java index 6db3df0fa..084a6bbe8 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Lists/RecipeType.java @@ -80,8 +80,7 @@ public class RecipeType implements Keyed { if (machine.length() > 0) { this.key = new NamespacedKey(SlimefunPlugin.instance(), machine.toLowerCase(Locale.ROOT)); - } - else { + } else { this.key = new NamespacedKey(SlimefunPlugin.instance(), "unknown"); } } @@ -97,8 +96,7 @@ public class RecipeType implements Keyed { if (item instanceof SlimefunItemStack) { this.machine = ((SlimefunItemStack) item).getItemId(); - } - else { + } else { this.machine = ""; } } @@ -118,8 +116,7 @@ public class RecipeType implements Keyed { public void register(ItemStack[] recipe, ItemStack result) { if (consumer != null) { consumer.accept(recipe, result); - } - else { + } else { SlimefunItem slimefunItem = SlimefunItem.getByID(this.machine); if (slimefunItem instanceof MultiBlockMachine) { diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java index 45f42508e..c69a682ec 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/Category.java @@ -147,8 +147,7 @@ public class Category implements Keyed { if (this instanceof SeasonalCategory) { meta.setDisplayName(ChatColor.GOLD + name); - } - else { + } else { meta.setDisplayName(ChatColor.YELLOW + name); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java index ca4f39e17..95cda4cb6 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/SlimefunItem.java @@ -286,8 +286,7 @@ public class SlimefunItem implements Placeable { if (state == ItemState.ENABLED) { if (hidden) { category.remove(this); - } - else { + } else { category.add(this); } } @@ -385,41 +384,21 @@ public class SlimefunItem implements Placeable { // Not-configurable items will be enabled. // Any other settings will remain as default. state = ItemState.ENABLED; - } - else if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) { + } else if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) { state = ItemState.ENABLED; useableInWorkbench = SlimefunPlugin.getItemCfg().getBoolean(id + ".can-be-used-in-workbenches"); hidden = SlimefunPlugin.getItemCfg().getBoolean(id + ".hide-in-guide"); enchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-enchanting"); disenchantable = SlimefunPlugin.getItemCfg().getBoolean(id + ".allow-disenchanting"); - } - else if (this instanceof VanillaItem) { + } else if (this instanceof VanillaItem) { state = ItemState.VANILLA_FALLBACK; - } - else { + } else { state = ItemState.DISABLED; } // Now we can be certain this item should be enabled if (state == ItemState.ENABLED) { - // Register the Category too if it hasn't been registered yet - if (!category.isRegistered()) { - category.register(); - } - - // Send out deprecation warnings for any classes or intefaces - checkForDeprecations(getClass()); - - // Add it to the list of enabled items - SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); - - // Load our Item Handlers - loadItemHandlers(); - - // Properly mark this Item as radioactive - if (this instanceof Radioactive) { - SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); - } + onEnable(); } // Lock the SlimefunItemStack from any accidental manipulations @@ -434,26 +413,52 @@ public class SlimefunItem implements Placeable { info("Item was registered during runtime."); load(); } - } - catch (Exception x) { + } catch (Exception x) { error("Registering " + toString() + " has failed!", x); } } + /** + * This method is called when this {@link SlimefunItem} is currently being registered + * and we are certain that it will be enabled. + * + * This method is for internal purposes, like {@link Category} registration only + */ + private final void onEnable() { + // Register the Category too if it hasn't been registered yet + if (!category.isRegistered()) { + category.register(); + } + + // Send out deprecation warnings for any classes or intefaces + checkForDeprecations(getClass()); + + // Add it to the list of enabled items + SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this); + + // Load our Item Handlers + loadItemHandlers(); + + // Properly mark this Item as radioactive + if (this instanceof Radioactive) { + SlimefunPlugin.getRegistry().getRadioactiveItems().add(this); + } + } + private void loadItemHandlers() { for (ItemHandler handler : itemhandlers.values()) { Optional exception = handler.validate(this); if (exception.isPresent()) { throw exception.get(); - } - else { + } else { // Make developers or at least Server admins aware that // an Item is using a deprecated ItemHandler checkForDeprecations(handler.getClass()); - // A bit too spammy atm, will enable it again later } + // If this ItemHandler is "public" (not bound to this SlimefunItem), + // we add it to the list of public Item handlers if (!handler.isPrivate()) { Set handlerset = getPublicItemHandlers(handler.getIdentifier()); handlerset.add(handler); @@ -633,8 +638,7 @@ public class SlimefunItem implements Placeable { if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) { boolean loreInsensitive = this instanceof Rechargeable || this instanceof SlimefunBackpack || id.equals("BROKEN_SPAWNER") || id.equals("REINFORCED_SPAWNER"); return SlimefunUtils.isItemSimilar(item, this.item, !loreInsensitive); - } - else { + } else { return false; } } @@ -649,8 +653,7 @@ public class SlimefunItem implements Placeable { } recipeType.register(recipe, getRecipeOutput()); - } - catch (Exception x) { + } catch (Exception x) { error("Failed to properly load the Item \"" + id + "\"", x); } } @@ -808,8 +811,7 @@ public class SlimefunItem implements Placeable { if (handler.isPresent()) { try { callable.accept(c.cast(handler.get())); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { error("Could not pass \"" + c.getSimpleName() + "\" for " + toString(), x); } @@ -832,8 +834,7 @@ public class SlimefunItem implements Placeable { public String toString() { if (addon == null) { return getClass().getSimpleName() + " - '" + id + "'"; - } - else { + } else { return getClass().getSimpleName() + " - '" + id + "' (" + addon.getName() + " v" + addon.getPluginVersion() + ')'; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java index d663fa2f3..0aa832c74 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AContainer.java @@ -167,7 +167,9 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, List displayRecipes = new ArrayList<>(recipes.size() * 2); for (MachineRecipe recipe : recipes) { - if (recipe.getInput().length != 1) continue; + if (recipe.getInput().length != 1) { + continue; + } displayRecipes.add(recipe.getInput()[0]); displayRecipes.add(recipe.getOutput()[0]); @@ -245,8 +247,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, removeCharge(b.getLocation(), getEnergyConsumption()); } progress.put(b, timeleft - 1); - } - else { + } else { inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " ")); for (ItemStack output : processing.get(b).getOutput()) { @@ -258,8 +259,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, progress.remove(b); processing.remove(b); } - } - else { + } else { MachineRecipe next = findNextRecipe(inv); if (next != null) { @@ -302,8 +302,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock, } return recipe; - } - else { + } else { found.clear(); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java index 1bb305799..8ce0163af 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/abstractItems/AGenerator.java @@ -59,8 +59,7 @@ public abstract class AGenerator extends AbstractEnergyProvider { public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { if (flow == ItemTransportFlow.INSERT) { return getInputSlots(); - } - else { + } else { return getOutputSlots(); } } @@ -150,13 +149,11 @@ public abstract class AGenerator extends AbstractEnergyProvider { } return 0; - } - else { + } else { progress.put(l, timeleft - 1); return getEnergyProduction(); } - } - else { + } else { ItemStack fuel = processing.get(l).getInput(); if (isBucket(fuel)) { @@ -171,8 +168,7 @@ public abstract class AGenerator extends AbstractEnergyProvider { processing.remove(l); return 0; } - } - else { + } else { Map found = new HashMap<>(); MachineFuel fuel = findRecipe(inv, found); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java index 9ba0a3df4..1a8d05854 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/Objects/SlimefunItem/interfaces/InventoryBlock.java @@ -47,8 +47,10 @@ public interface InventoryBlock { @Override public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { - if (flow == ItemTransportFlow.INSERT) return getInputSlots(); - else return getOutputSlots(); + if (flow == ItemTransportFlow.INSERT) + return getInputSlots(); + else + return getOutputSlots(); } @Override diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java index 5b525a1f2..8bc5dc5de 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockInfoConfig.java @@ -53,8 +53,7 @@ public class BlockInfoConfig extends Config { if (value == null) { data.remove(path); - } - else { + } else { data.put(path, (String) value); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java index 4f0ec5e90..f94f9bf64 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/BlockStorage.java @@ -92,8 +92,7 @@ public class BlockStorage { if (w != null) { return new Location(w, Integer.parseInt(components[1]), Integer.parseInt(components[2]), Integer.parseInt(components[3])); } - } - catch (NumberFormatException x) { + } catch (NumberFormatException x) { Slimefun.getLogger().log(Level.WARNING, "Could not parse Number", x); } return null; @@ -118,8 +117,7 @@ public class BlockStorage { if (dir.exists()) { loadBlocks(dir); - } - else { + } else { dir.mkdirs(); } @@ -143,8 +141,7 @@ public class BlockStorage { Slimefun.getLogger().log(Level.WARNING, "File with corrupted blocks detected!"); Slimefun.getLogger().log(Level.WARNING, "Slimefun will simply skip this File, you should look inside though!"); Slimefun.getLogger().log(Level.WARNING, file.getPath()); - } - else if (file.getName().endsWith(".sfb")) { + } else if (file.getName().endsWith(".sfb")) { if (timestamp + delay < System.currentTimeMillis()) { int progress = Math.round((((done * 100.0F) / total) * 100.0F) / 100.0F); Slimefun.getLogger().log(Level.INFO, "Loading Blocks... {0}% done (\"{1}\")", new Object[] { progress, world.getName() }); @@ -161,8 +158,7 @@ public class BlockStorage { done++; } } - } - finally { + } finally { long time = (System.currentTimeMillis() - start); Slimefun.getLogger().log(Level.INFO, "Loading Blocks... 100% (FINISHED - {0}ms)", time); Slimefun.getLogger().log(Level.INFO, "Loaded a total of {0} Blocks for World \"{1}\"", new Object[] { totalBlocks, world.getName() }); @@ -205,8 +201,7 @@ public class BlockStorage { locations.add(l); } } - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.WARNING, x, () -> "Failed to load " + file.getName() + '(' + key + ") for Slimefun " + SlimefunPlugin.getVersion()); } } @@ -223,8 +218,7 @@ public class BlockStorage { BlockInfoConfig data = new BlockInfoConfig(parseJSON(cfg.getString(key))); SlimefunPlugin.getRegistry().getChunks().put(key, data); } - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.WARNING, x, () -> "Failed to load " + chunks.getName() + " in World " + world.getName() + '(' + key + ") for Slimefun " + SlimefunPlugin.getVersion()); } } @@ -246,8 +240,7 @@ public class BlockStorage { if (preset != null) { inventories.put(l, new BlockMenu(preset, l, cfg)); } - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while loading this Block Inventory: " + file.getName()); } } @@ -262,8 +255,7 @@ public class BlockStorage { if (preset != null) { SlimefunPlugin.getRegistry().getUniversalInventories().put(preset.getID(), new UniversalBlockMenu(preset, cfg)); } - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while loading this universal Inventory: " + file.getName()); } } @@ -308,20 +300,17 @@ public class BlockStorage { if (file.exists()) { try { Files.delete(file.toPath()); - } - catch (IOException e) { + } catch (IOException e) { Slimefun.getLogger().log(Level.WARNING, e, () -> "Could not delete file \"" + file.getName() + '"'); } } - } - else { + } else { File tmpFile = new File(cfg.getFile().getParentFile(), cfg.getFile().getName() + ".tmp"); cfg.save(tmpFile); try { Files.move(tmpFile.toPath(), cfg.getFile().toPath(), StandardCopyOption.ATOMIC_MOVE); - } - catch (IOException x) { + } catch (IOException x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while copying a temporary File for Slimefun " + SlimefunPlugin.getVersion()); } } @@ -389,16 +378,14 @@ public class BlockStorage { public static ItemStack retrieve(Block block) { if (!hasBlockInfo(block)) { return null; - } - else { + } else { String id = getLocationInfo(block.getLocation(), "id"); SlimefunItem item = SlimefunItem.getByID(id); clearBlockInfo(block); if (item == null) { return null; - } - else { + } else { return item.getItem(); } } @@ -435,8 +422,7 @@ public class BlockStorage { private static BlockInfoConfig parseBlockInfo(Location l, String json) { try { return new BlockInfoConfig(parseJSON(json)); - } - catch (Exception x) { + } catch (Exception x) { Logger logger = Slimefun.getLogger(); logger.log(Level.WARNING, x.getClass().getName()); logger.log(Level.WARNING, "Failed to parse BlockInfo for Block @ {0}, {1}, {2}", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ() }); @@ -462,8 +448,7 @@ public class BlockStorage { writer.endObject(); return string.toString(); - } - catch (IOException x) { + } catch (IOException x) { Slimefun.getLogger().log(Level.SEVERE, "An error occurred while serializing BlockInfo", x); return null; } @@ -506,8 +491,7 @@ public class BlockStorage { if (storage != null) { Config cfg = storage.storage.get(l); return cfg != null && cfg.getString("id") != null; - } - else { + } else { return false; } } @@ -532,16 +516,14 @@ public class BlockStorage { if (!SlimefunPlugin.getRegistry().getUniversalInventories().containsKey(id)) { storage.loadUniversalInventory(BlockMenuPreset.getPreset(id)); } - } - else if (!storage.hasInventory(l)) { + } else if (!storage.hasInventory(l)) { File file = new File(PATH_INVENTORIES + serializeLocation(l) + ".sfi"); BlockMenuPreset preset = BlockMenuPreset.getPreset(id); if (file.exists()) { BlockMenu inventory = new BlockMenu(preset, l, new io.github.thebusybiscuit.cscorelib2.config.Config(file)); storage.inventories.put(l, inventory); - } - else { + } else { storage.loadInventory(l, preset); } } @@ -740,8 +722,7 @@ public class BlockStorage { try { String id = getLocationInfo(l, "id"); return id != null && id.equalsIgnoreCase(slimefunItem); - } - catch (Exception x) { + } catch (Exception x) { Slimefun.getLogger().log(Level.SEVERE, x, () -> "An Exception occurred while checking " + new BlockPosition(l) + " for: \"" + slimefunItem + "\""); return false; } @@ -826,8 +807,7 @@ public class BlockStorage { if (storage == null) { return false; - } - else { + } else { return storage.hasInventory(b.getLocation()); } } @@ -843,8 +823,7 @@ public class BlockStorage { if (menu != null) { return menu; - } - else { + } else { return storage.loadInventory(l, BlockMenuPreset.getPreset(checkID(l))); } } @@ -864,8 +843,7 @@ public class BlockStorage { } return cfg; - } - catch (Exception e) { + } catch (Exception e) { Slimefun.getLogger().log(Level.SEVERE, e, () -> "Failed to parse ChunkInfo for Slimefun " + SlimefunPlugin.getVersion()); return emptyBlockData; } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java index f13ba5bb0..2507d50bb 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/Slimefun.java @@ -49,8 +49,7 @@ public final class Slimefun { if (sfItem != null) { return hasUnlocked(p, sfItem, message); - } - else { + } else { return true; } } @@ -76,8 +75,7 @@ public final class Slimefun { if (isEnabled(p, sfItem, message) && hasPermission(p, sfItem, message)) { if (sfItem.getResearch() == null) { return true; - } - else { + } else { Optional profile = PlayerProfile.find(p); if (!profile.isPresent()) { @@ -85,11 +83,9 @@ public final class Slimefun { // But we will schedule the Profile for loading. PlayerProfile.request(p); return false; - } - else if (profile.get().hasUnlocked(sfItem.getResearch())) { + } else if (profile.get().hasUnlocked(sfItem.getResearch())) { return true; - } - else { + } else { if (message && !(sfItem instanceof VanillaItem)) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.not-researched", true); } @@ -118,11 +114,9 @@ public final class Slimefun { public static boolean hasPermission(Player p, SlimefunItem item, boolean message) { if (item == null) { return true; - } - else if (SlimefunPlugin.getPermissionsService().hasPermission(p, item)) { + } else if (SlimefunPlugin.getPermissionsService().hasPermission(p, item)) { return true; - } - else { + } else { if (message) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.no-permission", true); } @@ -170,8 +164,7 @@ public final class Slimefun { } return false; - } - else if (!SlimefunPlugin.getWorldSettingsService().isEnabled(p.getWorld(), sfItem)) { + } else if (!SlimefunPlugin.getWorldSettingsService().isEnabled(p.getWorld(), sfItem)) { if (message) { SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-in-world", true); } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java index 8f78c8a11..abd54af89 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/SlimefunItemStack.java @@ -274,11 +274,9 @@ public class SlimefunItemStack extends CustomItem { if (texture.startsWith("ey")) { return texture; - } - else if (PatternUtils.ALPHANUMERIC.matcher(texture).matches()) { + } else if (PatternUtils.ALPHANUMERIC.matcher(texture).matches()) { return Base64.getEncoder().encodeToString(("{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}").getBytes(StandardCharsets.UTF_8)); - } - else { + } else { throw new IllegalArgumentException("The provided texture for Item \"" + id + "\" does not seem to be a valid texture String!"); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java index 5a93f61c0..bb0017503 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenu.java @@ -33,7 +33,8 @@ public class BlockMenu extends DirtyChestMenu { this.location = l; for (int i = 0; i < 54; i++) { - if (cfg.contains(String.valueOf(i))) addItem(i, cfg.getItem(String.valueOf(i))); + if (cfg.contains(String.valueOf(i))) + addItem(i, cfg.getItem(String.valueOf(i))); } preset.clone(this); @@ -113,8 +114,7 @@ public class BlockMenu extends DirtyChestMenu { if (file.exists()) { try { Files.delete(file.toPath()); - } - catch (IOException e) { + } catch (IOException e) { Slimefun.getLogger().log(Level.WARNING, e, () -> "Could not delete file \"" + file.getName() + '"'); } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java index be7877c56..1a1a0ebb3 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/BlockMenuPreset.java @@ -143,8 +143,7 @@ public abstract class BlockMenuPreset extends ChestMenu { if (size % 9 == 0 && size >= 0 && size < 55) { this.size = size; return this; - } - else { + } else { throw new IllegalArgumentException("The size of a BlockMenuPreset must be a multiple of 9 and within the bounds 0-54, received: " + size); } } @@ -197,8 +196,7 @@ public abstract class BlockMenuPreset extends ChestMenu { emptySlots.add(i); } } - } - else { + } else { for (int i = 0; i < size; i++) { if (!occupiedSlots.contains(i)) { emptySlots.add(i); @@ -244,8 +242,7 @@ public abstract class BlockMenuPreset extends ChestMenu { try { newInstance(menu, l.getBlock()); - } - catch (Exception | LinkageError x) { + } catch (Exception | LinkageError x) { getSlimefunItem().error("An Error occurred while trying to create a BlockMenu", x); } }); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java index 86696d817..412e531c1 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/DirtyChestMenu.java @@ -84,8 +84,7 @@ public class DirtyChestMenu extends ChestMenu { public ChestMenu addMenuOpeningHandler(MenuOpeningHandler handler) { if (handler instanceof SaveHandler) { return super.addMenuOpeningHandler(new SaveHandler(this, ((SaveHandler) handler).getOpeningHandler())); - } - else { + } else { return super.addMenuOpeningHandler(new SaveHandler(this, handler)); } } @@ -94,8 +93,7 @@ public class DirtyChestMenu extends ChestMenu { if (getItemInSlot(slots[0]) == null) { // Very small optimization return true; - } - else { + } else { return InvUtils.fits(toInventory(), new ItemStackWrapper(item), slots); } } @@ -119,8 +117,7 @@ public class DirtyChestMenu extends ChestMenu { if (stack == null) { replaceExistingItem(slot, item); return null; - } - else if (stack.getAmount() < stack.getMaxStackSize()) { + } else if (stack.getAmount() < stack.getMaxStackSize()) { if (wrapper == null) { wrapper = new ItemStackWrapper(item); } @@ -135,8 +132,7 @@ public class DirtyChestMenu extends ChestMenu { if (amount > 0) { return new CustomItem(item, amount); - } - else { + } else { return null; } } diff --git a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java index a61bb8abc..11efc88e8 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/api/inventory/UniversalBlockMenu.java @@ -33,7 +33,8 @@ public class UniversalBlockMenu extends DirtyChestMenu { } public void save() { - if (!isDirty()) return; + if (!isDirty()) + return; // To force CS-CoreLib to build the Inventory this.getContents(); diff --git a/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java b/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java index 217ecd8a1..5f44303db 100644 --- a/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java +++ b/src/main/java/me/mrCookieSlime/Slimefun/bstats/bukkit/Metrics.java @@ -115,8 +115,7 @@ public class Metrics { config.options().header("bStats collects some data for plugin authors like how many servers are using their plugins.\n" + "To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" + "Check out https://bStats.org/ to learn more :)").copyDefaults(true); try { config.save(configFile); - } - catch (IOException ignored) {} + } catch (IOException ignored) {} } // Load the data @@ -134,8 +133,7 @@ public class Metrics { service.getField("B_STATS_VERSION"); // Our identifier :) found = true; // We aren't the first break; - } - catch (NoSuchFieldException ignored) {} + } catch (NoSuchFieldException ignored) {} } // Register our service Bukkit.getServicesManager().register(Metrics.class, this, plugin, ServicePriority.Normal); @@ -235,8 +233,7 @@ public class Metrics { // This fixes java.lang.NoSuchMethodError: org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection; Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers"); playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection) onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length; - } - catch (Exception e) { + } catch (Exception e) { playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed } int onlineMode = Bukkit.getOnlineMode() ? 1 : 0; @@ -285,8 +282,7 @@ public class Metrics { Object plugin = provider.getService().getMethod("getPluginData").invoke(provider.getProvider()); if (plugin instanceof JsonObject) { pluginData.add((JsonObject) plugin); - } - else { // old bstats version compatibility + } else { // old bstats version compatibility try { Class jsonObjectJsonSimple = Class.forName("org.json.simple.JSONObject"); if (plugin.getClass().isAssignableFrom(jsonObjectJsonSimple)) { @@ -296,19 +292,16 @@ public class Metrics { JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject(); pluginData.add(object); } - } - catch (ClassNotFoundException e) { + } catch (ClassNotFoundException e) { // minecraft version 1.14+ if (logFailedRequests) { this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception", e); } } } - } - catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} + } catch (NullPointerException | NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {} } - } - catch (NoSuchFieldException ignored) {} + } catch (NoSuchFieldException ignored) {} } data.add("plugins", pluginData); @@ -318,8 +311,7 @@ public class Metrics { try { // Send the data sendData(plugin, data); - } - catch (Exception e) { + } catch (Exception e) { // Something went wrong! :( if (logFailedRequests) { plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e); @@ -432,8 +424,7 @@ public class Metrics { return null; } chart.add("data", data); - } - catch (Throwable t) { + } catch (Throwable t) { if (logFailedRequests) { Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 5c84cd1a9..f0aaf77fd 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -61,6 +61,9 @@ permissions: slimefun.inventory.bypass: description: Allows you to open all Slimefun Machines default: op + slimefun.gps.bypass: + description: Allows you to open all GPS inventories + default: op slimefun.debugging: description: Allows you to use the debugging tool from Slimefun default: op diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/annotations/SlimefunItemsProvider.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/annotations/SlimefunItemsProvider.java index 300386a6e..23fd2e5dc 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/annotations/SlimefunItemsProvider.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/annotations/SlimefunItemsProvider.java @@ -32,8 +32,7 @@ public class SlimefunItemsProvider implements ArgumentsProvider, AnnotationConsu try { field = clazz.getField(fieldName); return (ItemStack) field.get(null); - } - catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { + } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) { throw new IllegalArgumentException("Could not find field SlimefunItems." + fieldName); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java index 6a964506e..0ecd6989f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/commands/TestChargeCommand.java @@ -60,7 +60,6 @@ class TestChargeCommand { Assertions.assertEquals(chargedItem.getItemCharge(chargedItemStack), chargedItem.getMaxItemCharge(chargedItemStack)); } - private class RechargeableMock extends SlimefunItem implements Rechargeable { public RechargeableMock(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java index b4edce537..490de2e34 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/TestSlimefunItemRegistration.java @@ -171,8 +171,7 @@ public class TestSlimefunItemRegistration { Assertions.assertTrue(sfItem.isItem(new CustomItem(Material.BEACON, "&cItem Test"))); SlimefunPlugin.getRegistry().setBackwardsCompatible(false); - } - else { + } else { Assertions.assertFalse(sfItem.isItem(item)); Assertions.assertFalse(sfItem.isItem(new CustomItem(Material.BEACON, "&cItem Test"))); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java index f8711a9bb..b53c951fd 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/items/implementations/tools/TestClimbingPick.java @@ -73,8 +73,7 @@ class TestClimbingPick implements SlimefunItemTest { if (shouldFireEvent) { server.getPluginManager().assertEventFired(ClimbingPickLaunchEvent.class); Assertions.assertTrue(player.getVelocity().length() > 0); - } - else { + } else { Assertions.assertEquals(0, player.getVelocity().length()); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBeeListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBeeListener.java index c154d93a8..a74f4016f 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBeeListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestBeeListener.java @@ -66,8 +66,7 @@ class TestBeeListener { if (hasArmor) { Assertions.assertEquals(0, event.getDamage()); - } - else { + } else { Assertions.assertEquals(damage, event.getDamage()); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java index 020522d7e..2f2721a44 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestIronGolemListener.java @@ -47,8 +47,7 @@ class TestIronGolemListener { if (hand == EquipmentSlot.HAND) { player.getInventory().setItemInMainHand(itemInHand); - } - else { + } else { player.getInventory().setItemInOffHand(itemInHand); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java index 1958fe761..7ee7b04f8 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestItemPickupListener.java @@ -53,7 +53,7 @@ class TestItemPickupListener { if (flag) { SlimefunUtils.markAsNoPickup(item, "Unit Test"); } - + EntityPickupItemEvent event = new EntityPickupItemEvent(player, item, 1); listener.onEntityPickup(event); @@ -69,13 +69,13 @@ class TestItemPickupListener { if (flag) { SlimefunUtils.markAsNoPickup(item, "Unit Test"); } - + InventoryPickupItemEvent event = new InventoryPickupItemEvent(inventory, item); listener.onHopperPickup(event); Assertions.assertEquals(flag, event.isCancelled()); } - + @ParameterizedTest @ValueSource(booleans = { true, false }) void testAltarProbeForEntities(boolean flag) { @@ -84,27 +84,26 @@ class TestItemPickupListener { if (flag) { stack = new CustomItem(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime()); - } - else { + } else { stack = new CustomItem(Material.DIAMOND, "&5Just a normal named diamond"); } - + AtomicBoolean removed = new AtomicBoolean(false); Item item = new ItemEntityMock(server, UUID.randomUUID(), stack) { - + @Override public void remove() { removed.set(true); } }; - + EntityPickupItemEvent event = new EntityPickupItemEvent(player, item, 1); listener.onEntityPickup(event); Assertions.assertEquals(flag, event.isCancelled()); Assertions.assertEquals(flag, removed.get()); } - + @ParameterizedTest @ValueSource(booleans = { true, false }) void testAltarProbeForInventories(boolean flag) { @@ -113,14 +112,13 @@ class TestItemPickupListener { if (flag) { stack = new CustomItem(Material.DIAMOND, AncientPedestal.ITEM_PREFIX + System.nanoTime()); - } - else { + } else { stack = new CustomItem(Material.DIAMOND, "&5Just a normal named diamond"); } - + AtomicBoolean removed = new AtomicBoolean(false); Item item = new ItemEntityMock(server, UUID.randomUUID(), stack) { - + @Override public void remove() { removed.set(true); diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestPiglinListener.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestPiglinListener.java index 8feb37334..dbb943171 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestPiglinListener.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/listeners/TestPiglinListener.java @@ -64,8 +64,7 @@ class TestPiglinListener { if (hand == EquipmentSlot.OFF_HAND) { player.getInventory().setItemInOffHand(item); - } - else { + } else { player.getInventory().setItemInMainHand(item); } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/networks/MockNetwork.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/networks/MockNetwork.java index 7fa9e0b61..befe59764 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/networks/MockNetwork.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/networks/MockNetwork.java @@ -28,8 +28,7 @@ class MockNetwork extends Network { public NetworkComponent classifyLocation(Location l) { if (l.equals(regulator)) { return NetworkComponent.REGULATOR; - } - else { + } else { return locations.get(l); } } diff --git a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestItemStackWrapper.java b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestItemStackWrapper.java index e58748a39..1c71fca13 100644 --- a/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestItemStackWrapper.java +++ b/src/test/java/io/github/thebusybiscuit/slimefun4/testing/tests/utils/TestItemStackWrapper.java @@ -98,8 +98,7 @@ class TestItemStackWrapper { private void assertWrapped(ItemStack expected, ItemStack actual) { if (expected == null) { Assertions.assertNull(actual); - } - else { + } else { Assertions.assertTrue(actual instanceof ItemStackWrapper); Assertions.assertTrue(SlimefunUtils.isItemSimilar(actual, expected, true)); }