mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Merge pull request #3139 from Slimefun/breaking-changes/class-relocation
⚠️ BREAKING CHANGES ⚠️ - Relocation of important API classes.
This commit is contained in:
commit
7b4c9d93fa
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,5 +1,5 @@
|
||||
# Table of contents
|
||||
- [Release Candidate 27 (TBD)](#release-candidate-27-tbd)
|
||||
- [Release Candidate 27 (03 Sep 2021)](#release-candidate-27-03-sep-2021)
|
||||
- [Release Candidate 26 (20 Jul 2021)](#release-candidate-26-20-jul-2021)
|
||||
- [Release Candidate 25 (20 Jun 2021)](#release-candidate-25-20-jun-2021)
|
||||
- [Release Candidate 24 (03 Jun 2021)](#release-candidate-24-03-jun-2021)
|
||||
@ -27,7 +27,20 @@
|
||||
- [Release Candidate 2 (29 Sep 2019)](#release-candidate-2-29-sep-2019)
|
||||
- [Release Candidate 1 (26 Sep 2019)](#release-candidate-1-26-sep-2019)
|
||||
|
||||
## Release Candidate 27 (TBD)
|
||||
## Release Candidate 27 (03 Sep 2021)
|
||||
|
||||
### **Breaking Changes (API)**
|
||||
This RC brings a lot of breaking changes to the API. For more info on why we did this and what happened [please refer to our PSA](https://github.com/Slimefun/Slimefun4/pull/3139)
|
||||
|
||||
* Category has been renamed to ItemGroup.
|
||||
* All Category / ItemGroup variants have been relocated to `io.github.thebusybiscuit.slimefun4.api.items.groups`
|
||||
* The SlimefunItem class has been relocated to `io.github.thebusybiscuit.slimefun4.api.items`
|
||||
* The SlimefunItemStack class has been relocated to `io.github.thebusybiscuit.slimefun4.api.items`
|
||||
* The ItemHandler class has been relocated to `io.github.thebusybiscuit.slimefun4.api.items`
|
||||
* The RecipeType class has been relocated to `io.github.thebusybiscuit.slimefun4.api.recipes`
|
||||
* Research classes have been moved from `io.github.thebusybiscuit.slimefun4.core.researching` to `io.github.thebusybiscuit.slimefun4.api.researches`
|
||||
* The main class `SlimefunPlugin` was renamed to `Slimefun`
|
||||
* CS-CoreLib2 was removed and replaced by dough
|
||||
|
||||
#### Additions
|
||||
* A couple more items have their wiki page linked ingame now
|
||||
@ -46,6 +59,7 @@
|
||||
* Slimefun chains can no longer be placed down
|
||||
* (API) FlexCategories can now also appear in non-survival Slimefun guides
|
||||
* Display items from Ancient Altars should no longer despawn so easily/fast
|
||||
* Research message was modified to also show the category of the item
|
||||
|
||||
#### Fixes
|
||||
* Fixed #3164
|
||||
|
62
pom.xml
62
pom.xml
@ -66,7 +66,7 @@
|
||||
<url>https://papermc.io/repo/repository/maven-public</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<!-- CS-CoreLib2, ItemsAdder -->
|
||||
<!-- ItemsAdder -->
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
@ -197,8 +197,8 @@
|
||||
<!-- Relocate these to avoid clashes and conflicts -->
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>io.github.thebusybiscuit.cscorelib2</pattern>
|
||||
<shadedPattern>me.mrCookieSlime.Slimefun.cscorelib2</shadedPattern>
|
||||
<pattern>io.github.bakedlibs.dough</pattern>
|
||||
<shadedPattern>io.github.thebusybiscuit.slimefun4.libraries.dough</shadedPattern>
|
||||
</relocation>
|
||||
<relocation>
|
||||
<pattern>io.papermc.lib</pattern>
|
||||
@ -344,6 +344,34 @@
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Shaded packages -->
|
||||
<dependency>
|
||||
<groupId>io.github.baked-libs</groupId>
|
||||
<artifactId>dough-api</artifactId>
|
||||
<version>1.0.2</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.konghq</groupId>
|
||||
<artifactId>unirest-java</artifactId>
|
||||
<version>3.11.12</version>
|
||||
<scope>compile</scope>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- No need to shade Gson, Spigot does that already -->
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Testing dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
@ -373,34 +401,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Shaded packages -->
|
||||
<dependency>
|
||||
<groupId>com.github.thebusybiscuit</groupId>
|
||||
<artifactId>CS-CoreLib2</artifactId>
|
||||
<version>0.32.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.papermc</groupId>
|
||||
<artifactId>paperlib</artifactId>
|
||||
<version>1.0.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.konghq</groupId>
|
||||
<artifactId>unirest-java</artifactId>
|
||||
<version>3.11.13</version>
|
||||
<scope>compile</scope>
|
||||
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<!-- No need to shade Gson, Spigot does that already -->
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Third party plugin integrations / soft dependencies -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
|
@ -21,10 +21,11 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.papermc.lib.PaperLib;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
@ -68,7 +69,7 @@ public class ErrorReport<T extends Throwable> {
|
||||
this.throwable = throwable;
|
||||
this.addon = addon;
|
||||
|
||||
SlimefunPlugin.runSync(() -> print(printer));
|
||||
Slimefun.runSync(() -> print(printer));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -182,7 +183,7 @@ public class ErrorReport<T extends Throwable> {
|
||||
stream.println();
|
||||
|
||||
stream.println("Slimefun Environment:");
|
||||
stream.println(" Slimefun v" + SlimefunPlugin.getVersion());
|
||||
stream.println(" Slimefun v" + Slimefun.getVersion());
|
||||
stream.println(" Caused by: " + addon.getName() + " v" + addon.getPluginVersion());
|
||||
stream.println();
|
||||
|
||||
@ -218,7 +219,7 @@ public class ErrorReport<T extends Throwable> {
|
||||
|
||||
addon.getLogger().log(Level.WARNING, "");
|
||||
} catch (Exception x) {
|
||||
addon.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving an Error-Report for Slimefun " + SlimefunPlugin.getVersion());
|
||||
addon.getLogger().log(Level.SEVERE, x, () -> "An Error occurred while saving an Error-Report for Slimefun " + Slimefun.getVersion());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ import javax.annotation.Nonnull;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Server;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
/**
|
||||
@ -14,7 +14,7 @@ import io.papermc.lib.PaperLib;
|
||||
* @author TheBusyBiscuit
|
||||
* @author Walshy
|
||||
*
|
||||
* @see SlimefunPlugin
|
||||
* @see Slimefun
|
||||
*
|
||||
*/
|
||||
public enum MinecraftVersion {
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This is a very basic interface that will be used to identify
|
||||
|
@ -4,7 +4,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
|
||||
/**
|
||||
* This enum represents the branch this Slimefun build is on.
|
||||
@ -50,7 +50,7 @@ public enum SlimefunBranch {
|
||||
this.name = name;
|
||||
this.official = official;
|
||||
|
||||
if (!PatternUtils.ASCII.matcher(name).matches()) {
|
||||
if (!CommonPatterns.ASCII.matcher(name).matches()) {
|
||||
throw new IllegalStateException("The SlimefunBranch enum contains ILLEGAL CHARACTERS. DO NOT TRANSLATE THIS FILE.");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@ -9,7 +8,9 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
|
||||
|
||||
/**
|
||||
* An {@link Event} that is called whenever an {@link AutoEnchanter} is
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition;
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
|
||||
import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor;
|
||||
|
||||
|
@ -2,12 +2,13 @@ package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
|
||||
|
||||
/**
|
||||
* An {@link Event} that is called whenever an {@link AutoEnchanter} is trying to enchant
|
||||
* an {@link ItemStack}.
|
||||
|
@ -11,8 +11,8 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.block.BlockEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This {@link Event} is fired whenever a {@link BlockPlacer} wants to place a {@link Block}.
|
||||
|
@ -1,6 +1,10 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -10,9 +14,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.ExplosiveTool;
|
||||
|
||||
/**
|
||||
* This {@link Event} is called when an {@link ExplosiveTool} is used to break blocks.
|
||||
|
@ -9,10 +9,10 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This {@link Event} is called whenever a {@link Player} clicks to unlock a {@link Research}.
|
||||
|
@ -16,8 +16,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.TriStateOptional;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.bakedlibs.dough.data.TriStateOptional;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
/**
|
||||
|
@ -7,8 +7,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* The {@link ReactorExplodeEvent} is called whenever a reactor explodes.
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
|
||||
/**
|
||||
* This {@link Event} is called whenever a {@link Player} unlocks a {@link Research}.
|
||||
|
@ -2,7 +2,7 @@ package io.github.thebusybiscuit.slimefun4.api.exceptions;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* An {@link IdConflictException} is thrown whenever two Addons try to add
|
||||
|
@ -4,9 +4,9 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
/**
|
||||
* An {@link IncompatibleItemHandlerException} is thrown whenever a {@link Plugin} tried
|
||||
|
@ -4,7 +4,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* An {@link UnregisteredItemException} is thrown whenever a {@link Plugin} tried to
|
||||
|
@ -4,9 +4,9 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.DamageableItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
* A {@link WrongItemStackException} is thrown when someone tries to alter an {@link ItemStack}
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||
|
||||
@ -83,7 +83,7 @@ public interface GEOResource extends Keyed {
|
||||
* Registers this GEO Resource
|
||||
*/
|
||||
default void register() {
|
||||
SlimefunPlugin.getGPSNetwork().getResourceManager().register(this);
|
||||
Slimefun.getGPSNetwork().getResourceManager().register(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,7 +96,7 @@ public interface GEOResource extends Keyed {
|
||||
*/
|
||||
@Nonnull
|
||||
default String getName(@Nonnull Player p) {
|
||||
String name = SlimefunPlugin.getLocalization().getResourceString(p, "resources." + getKey().getNamespace() + "." + getKey().getKey());
|
||||
String name = Slimefun.getLocalization().getResourceString(p, "resources." + getKey().getNamespace() + "." + getKey().getKey());
|
||||
return name == null ? getName() : name;
|
||||
}
|
||||
|
||||
|
@ -20,16 +20,17 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition;
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
@ -53,9 +54,9 @@ public class ResourceManager {
|
||||
* This will create a new {@link ResourceManager}.
|
||||
*
|
||||
* @param plugin
|
||||
* Our {@link SlimefunPlugin} instance
|
||||
* Our {@link Slimefun} instance
|
||||
*/
|
||||
public ResourceManager(@Nonnull SlimefunPlugin plugin) {
|
||||
public ResourceManager(@Nonnull Slimefun plugin) {
|
||||
config = new Config(plugin, "resources.yml");
|
||||
}
|
||||
|
||||
@ -71,7 +72,7 @@ public class ResourceManager {
|
||||
Validate.notNull(resource.getKey(), "GEO-Resources must have a NamespacedKey which is not null");
|
||||
|
||||
// Resources may only be registered once
|
||||
if (SlimefunPlugin.getRegistry().getGEOResources().containsKey(resource.getKey())) {
|
||||
if (Slimefun.getRegistry().getGEOResources().containsKey(resource.getKey())) {
|
||||
throw new IllegalArgumentException("GEO-Resource \"" + resource.getKey() + "\" has already been registered!");
|
||||
}
|
||||
|
||||
@ -79,10 +80,10 @@ public class ResourceManager {
|
||||
boolean enabled = config.getOrSetDefault(key + ".enabled", true);
|
||||
|
||||
if (enabled) {
|
||||
SlimefunPlugin.getRegistry().getGEOResources().add(resource);
|
||||
Slimefun.getRegistry().getGEOResources().add(resource);
|
||||
}
|
||||
|
||||
if (SlimefunPlugin.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) {
|
||||
if (Slimefun.getMinecraftVersion() != MinecraftVersion.UNIT_TEST) {
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
@ -211,23 +212,23 @@ public class ResourceManager {
|
||||
* The page to display
|
||||
*/
|
||||
public void scan(@Nonnull Player p, @Nonnull Block block, int page) {
|
||||
if (SlimefunPlugin.getGPSNetwork().getNetworkComplexity(p.getUniqueId()) < 600) {
|
||||
SlimefunPlugin.getLocalization().sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600"));
|
||||
if (Slimefun.getGPSNetwork().getNetworkComplexity(p.getUniqueId()) < 600) {
|
||||
Slimefun.getLocalization().sendMessages(p, "gps.insufficient-complexity", true, msg -> msg.replace("%complexity%", "600"));
|
||||
return;
|
||||
}
|
||||
|
||||
int x = block.getX() >> 4;
|
||||
int z = block.getZ() >> 4;
|
||||
|
||||
String title = "&4" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.results");
|
||||
String title = "&4" + Slimefun.getLocalization().getResourceString(p, "tooltips.results");
|
||||
ChestMenu menu = new ChestMenu(title);
|
||||
|
||||
for (int slot : backgroundSlots) {
|
||||
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
menu.addItem(4, new CustomItem(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler());
|
||||
List<GEOResource> resources = new ArrayList<>(SlimefunPlugin.getRegistry().getGEOResources().values());
|
||||
menu.addItem(4, new CustomItemStack(HeadTexture.MINECRAFT_CHUNK.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getResourceString(p, "tooltips.chunk"), "", "&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": " + block.getWorld().getName(), "&8\u21E8 &7X: " + x + " Z: " + z), ChestMenuUtils.getEmptyClickHandler());
|
||||
List<GEOResource> resources = new ArrayList<>(Slimefun.getRegistry().getGEOResources().values());
|
||||
resources.sort(Comparator.comparing(a -> a.getName(p).toLowerCase(Locale.ROOT)));
|
||||
|
||||
int index = 10;
|
||||
@ -237,9 +238,9 @@ public class ResourceManager {
|
||||
GEOResource resource = resources.get(i);
|
||||
OptionalInt optional = getSupplies(resource, block.getWorld(), x, z);
|
||||
int supplies = optional.isPresent() ? optional.getAsInt() : generate(resource, block.getWorld(), x, z);
|
||||
String suffix = SlimefunPlugin.getLocalization().getResourceString(p, supplies == 1 ? "tooltips.unit" : "tooltips.units");
|
||||
String suffix = Slimefun.getLocalization().getResourceString(p, supplies == 1 ? "tooltips.unit" : "tooltips.units");
|
||||
|
||||
ItemStack item = new CustomItem(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);
|
||||
ItemStack item = new CustomItemStack(resource.getItem(), "&f" + resource.getName(p), "&8\u21E8 &e" + supplies + ' ' + suffix);
|
||||
|
||||
if (supplies > 1) {
|
||||
item.setAmount(supplies > item.getMaxStackSize() ? item.getMaxStackSize() : supplies);
|
||||
|
@ -20,22 +20,23 @@ import org.bukkit.World.Environment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.chat.ChatInput;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.gps.GPSTransmitter;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
/**
|
||||
@ -63,9 +64,9 @@ public class GPSNetwork {
|
||||
* Note that this network is per {@link Server} and not per {@link Player}.
|
||||
*
|
||||
* @param plugin
|
||||
* Our {@link SlimefunPlugin} instance
|
||||
* Our {@link Slimefun} instance
|
||||
*/
|
||||
public GPSNetwork(@Nonnull SlimefunPlugin plugin) {
|
||||
public GPSNetwork(@Nonnull Slimefun plugin) {
|
||||
resourceManager = new ResourceManager(plugin);
|
||||
}
|
||||
|
||||
@ -140,24 +141,24 @@ public class GPSNetwork {
|
||||
* The {@link Player}
|
||||
*/
|
||||
public void openTransmitterControlPanel(@Nonnull Player p) {
|
||||
ChestMenu menu = new ChestMenu(ChatColor.BLUE + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
|
||||
ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
|
||||
|
||||
for (int slot : border) {
|
||||
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
menu.addItem(2, new CustomItem(SlimefunItems.GPS_TRANSMITTER, im -> {
|
||||
im.setDisplayName(ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
|
||||
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, im -> {
|
||||
im.setDisplayName(ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"));
|
||||
im.setLore(null);
|
||||
}));
|
||||
|
||||
menu.addMenuClickHandler(2, ChestMenuUtils.getEmptyClickHandler());
|
||||
|
||||
int complexity = getNetworkComplexity(p.getUniqueId());
|
||||
menu.addItem(4, new CustomItem(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
|
||||
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
|
||||
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
|
||||
|
||||
menu.addItem(6, new CustomItem(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
||||
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
||||
menu.addMenuClickHandler(6, (pl, slot, item, action) -> {
|
||||
openWaypointControlPanel(pl);
|
||||
return false;
|
||||
@ -174,7 +175,7 @@ public class GPSNetwork {
|
||||
if (sfi instanceof GPSTransmitter) {
|
||||
int slot = inventory[index];
|
||||
|
||||
menu.addItem(slot, new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
|
||||
menu.addItem(slot, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&bGPS Transmitter", "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &7Signal Strength: &f" + ((GPSTransmitter) sfi).getMultiplier(l.getBlockY()), "&8\u21E8 &7Ping: &f" + NumberUtils.roundDecimalNumber(1000D / l.getY()) + "ms"));
|
||||
menu.addMenuClickHandler(slot, ChestMenuUtils.getEmptyClickHandler());
|
||||
|
||||
index++;
|
||||
@ -214,23 +215,23 @@ public class GPSNetwork {
|
||||
|
||||
public void openWaypointControlPanel(@Nonnull Player p) {
|
||||
PlayerProfile.get(p, profile -> {
|
||||
ChestMenu menu = new ChestMenu(ChatColor.BLUE + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
|
||||
ChestMenu menu = new ChestMenu(ChatColor.BLUE + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.title"));
|
||||
|
||||
for (int slot : border) {
|
||||
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
menu.addItem(2, new CustomItem(SlimefunItems.GPS_TRANSMITTER, "&7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
||||
menu.addItem(2, new CustomItemStack(SlimefunItems.GPS_TRANSMITTER, "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.transmitters"), "", ChatColor.GRAY + "\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
||||
menu.addMenuClickHandler(2, (pl, slot, item, action) -> {
|
||||
openTransmitterControlPanel(pl);
|
||||
return false;
|
||||
});
|
||||
|
||||
int complexity = getNetworkComplexity(p.getUniqueId());
|
||||
menu.addItem(4, new CustomItem(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
|
||||
menu.addItem(4, new CustomItemStack(SlimefunItems.GPS_CONTROL_PANEL, "&7Network Info", "", "&8\u21E8 &7Status: " + (complexity > 0 ? "&2&lONLINE" : "&4&lOFFLINE"), "&8\u21E8 &7Complexity: &f" + complexity));
|
||||
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
|
||||
|
||||
menu.addItem(6, new CustomItem(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
|
||||
menu.addItem(6, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), "&7" + Slimefun.getLocalization().getMessage(p, "machines.GPS_CONTROL_PANEL.waypoints")));
|
||||
menu.addMenuClickHandler(6, ChestMenuUtils.getEmptyClickHandler());
|
||||
|
||||
int index = 0;
|
||||
@ -242,7 +243,7 @@ public class GPSNetwork {
|
||||
int slot = inventory[index];
|
||||
|
||||
Location l = waypoint.getLocation();
|
||||
menu.addItem(slot, new CustomItem(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete"));
|
||||
menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), "&8\u21E8 &7World: &f" + l.getWorld().getName(), "&8\u21E8 &7X: &f" + l.getX(), "&8\u21E8 &7Y: &f" + l.getY(), "&8\u21E8 &7Z: &f" + l.getZ(), "", "&8\u21E8 &cClick to delete"));
|
||||
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
|
||||
profile.removeWaypoint(waypoint);
|
||||
pl.playSound(pl.getLocation(), Sound.UI_BUTTON_CLICK, 1F, 1F);
|
||||
@ -273,14 +274,14 @@ public class GPSNetwork {
|
||||
|
||||
PlayerProfile.get(p, profile -> {
|
||||
if ((profile.getWaypoints().size() + 2) > inventory.length) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "gps.waypoint.max", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.max", true);
|
||||
return;
|
||||
}
|
||||
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "gps.waypoint.new", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.new", true);
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 0.5F, 1F);
|
||||
|
||||
ChatInput.waitForPlayer(SlimefunPlugin.instance(), p, message -> addWaypoint(p, message, l));
|
||||
ChatInput.waitForPlayer(Slimefun.instance(), p, message -> addWaypoint(p, message, l));
|
||||
});
|
||||
}
|
||||
|
||||
@ -301,11 +302,11 @@ public class GPSNetwork {
|
||||
|
||||
PlayerProfile.get(p, profile -> {
|
||||
if ((profile.getWaypoints().size() + 2) > inventory.length) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "gps.waypoint.max", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.max", true);
|
||||
return;
|
||||
}
|
||||
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
WaypointCreateEvent event = new WaypointCreateEvent(p, name, l);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
@ -314,7 +315,7 @@ public class GPSNetwork {
|
||||
|
||||
for (Waypoint wp : profile.getWaypoints()) {
|
||||
if (wp.getId().equals(id)) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "gps.waypoint.duplicate", true, msg -> msg.replace("%waypoint%", event.getName()));
|
||||
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.duplicate", true, msg -> msg.replace("%waypoint%", event.getName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -322,7 +323,7 @@ public class GPSNetwork {
|
||||
profile.addWaypoint(new Waypoint(profile, id, event.getLocation(), event.getName()));
|
||||
|
||||
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1F, 1F);
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "gps.waypoint.added", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "gps.waypoint.added", true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -19,15 +19,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
/**
|
||||
@ -63,7 +64,7 @@ public final class TeleportationManager {
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public void openTeleporterGUI(Player p, UUID ownerUUID, Block b) {
|
||||
openTeleporterGUI(p, ownerUUID, b, SlimefunPlugin.getGPSNetwork().getNetworkComplexity(ownerUUID));
|
||||
openTeleporterGUI(p, ownerUUID, b, Slimefun.getGPSNetwork().getNetworkComplexity(ownerUUID));
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
@ -79,7 +80,7 @@ public final class TeleportationManager {
|
||||
menu.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
menu.addItem(4, new CustomItem(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title")));
|
||||
menu.addItem(4, new CustomItemStack(HeadTexture.GLOBE_OVERWORLD.getAsItemStack(), ChatColor.YELLOW + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.title")));
|
||||
menu.addMenuClickHandler(4, ChestMenuUtils.getEmptyClickHandler());
|
||||
|
||||
Location source = new Location(b.getWorld(), b.getX() + 0.5D, b.getY() + 2D, b.getZ() + 0.5D);
|
||||
@ -97,17 +98,17 @@ public final class TeleportationManager {
|
||||
// @formatter:off
|
||||
String[] lore = {
|
||||
"",
|
||||
"&8\u21E8 &7" + SlimefunPlugin.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(),
|
||||
"&8\u21E8 &7" + Slimefun.getLocalization().getResourceString(p, "tooltips.world") + ": &f" + l.getWorld().getName(),
|
||||
"&8\u21E8 &7X: &f" + l.getX(),
|
||||
"&8\u21E8 &7Y: &f" + l.getY(),
|
||||
"&8\u21E8 &7Z: &f" + l.getZ(),
|
||||
"&8\u21E8 &7" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s",
|
||||
"&8\u21E8 &7" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.time") + ": &f" + time + "s",
|
||||
"",
|
||||
"&8\u21E8 &c" + SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip")
|
||||
"&8\u21E8 &c" + Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.gui.tooltip")
|
||||
};
|
||||
// @formatter:on
|
||||
|
||||
menu.addItem(slot, new CustomItem(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore));
|
||||
menu.addItem(slot, new CustomItemStack(waypoint.getIcon(), waypoint.getName().replace("player:death ", ""), lore));
|
||||
menu.addMenuClickHandler(slot, (pl, s, item, action) -> {
|
||||
pl.closeInventory();
|
||||
teleport(pl.getUniqueId(), complexity, source, l, false);
|
||||
@ -117,7 +118,7 @@ public final class TeleportationManager {
|
||||
index++;
|
||||
}
|
||||
|
||||
SlimefunPlugin.runSync(() -> menu.open(p));
|
||||
Slimefun.runSync(() -> menu.open(p));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -182,7 +183,7 @@ public final class TeleportationManager {
|
||||
teleporterUsers.remove(uuid);
|
||||
|
||||
if (p != null) {
|
||||
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), ChatColors.color("&c&k40&f&c%"), 20, 60, 20);
|
||||
p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.cancelled")), ChatColors.color("&c&k40&f&c%"), 20, 60, 20);
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,15 +193,15 @@ public final class TeleportationManager {
|
||||
|
||||
if (isValid(p, source)) {
|
||||
if (progress > 99) {
|
||||
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20);
|
||||
p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleported")), ChatColors.color("&b100%"), 20, 60, 20);
|
||||
PaperLib.teleportAsync(p, destination).thenAccept(success -> onTeleport(p, destination, success, resistance));
|
||||
} else {
|
||||
p.sendTitle(ChatColors.color(SlimefunPlugin.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0);
|
||||
p.sendTitle(ChatColors.color(Slimefun.getLocalization().getMessage(p, "machines.TELEPORTER.teleporting")), ChatColors.color("&b" + progress + "%"), 0, 60, 0);
|
||||
|
||||
source.getWorld().spawnParticle(Particle.PORTAL, source, progress * 2, 0.2F, 0.8F, 0.2F);
|
||||
source.getWorld().playSound(source, Sound.BLOCK_BEACON_AMBIENT, 1F, 0.6F);
|
||||
|
||||
SlimefunPlugin.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L);
|
||||
Slimefun.runSync(() -> updateProgress(uuid, speed, progress + speed, source, destination, resistance), 10L);
|
||||
}
|
||||
} else {
|
||||
cancel(uuid, p);
|
||||
@ -213,12 +214,12 @@ public final class TeleportationManager {
|
||||
* This needs to run on the main Thread so we force it, as
|
||||
* the async teleportation might happen on a separate Thread.
|
||||
*/
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
if (success) {
|
||||
// Apply Resistance Effect, if enabled
|
||||
if (resistance) {
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 600, 20));
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
|
||||
Slimefun.getLocalization().sendMessage(p, "machines.TELEPORTER.invulnerability");
|
||||
}
|
||||
|
||||
// Spawn some particles for aesthetic reasons.
|
||||
|
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.WaypointCreateEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.teleporter.Teleporter;
|
||||
|
||||
/**
|
||||
@ -118,7 +118,7 @@ public class Waypoint {
|
||||
*/
|
||||
@Nonnull
|
||||
public ItemStack getIcon() {
|
||||
return SlimefunPlugin.getGPSNetwork().getIcon(name, location.getWorld().getEnvironment());
|
||||
return Slimefun.getGPSNetwork().getIcon(name, location.getWorld().getEnvironment());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,6 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.ArmorTask;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This class serves as a way of checking whether a {@link Player} has changed their armor
|
||||
@ -95,8 +94,7 @@ public final class HashedArmorpiece {
|
||||
*
|
||||
* @return An {@link Optional} describing the result
|
||||
*/
|
||||
@Nonnull
|
||||
public Optional<SlimefunArmorPiece> getItem() {
|
||||
public @Nonnull Optional<SlimefunArmorPiece> getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -19,24 +19,23 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.core.categories.LockedCategory;
|
||||
import io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.groups.LockedItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.groups.SeasonalItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* Represents a category, which structure multiple {@link SlimefunItem} in the {@link SlimefunGuide}.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see LockedCategory
|
||||
* @see SeasonalCategory
|
||||
* @see LockedItemGroup
|
||||
* @see SeasonalItemGroup
|
||||
*
|
||||
*/
|
||||
public class Category implements Keyed {
|
||||
public class ItemGroup implements Keyed {
|
||||
|
||||
private SlimefunAddon addon;
|
||||
|
||||
@ -46,34 +45,35 @@ public class Category implements Keyed {
|
||||
protected int tier;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier
|
||||
* Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier
|
||||
* and the given {@link ItemStack} as its display item.
|
||||
* The tier is set to a default value of {@code 3}.
|
||||
*
|
||||
* @param key
|
||||
* The {@link NamespacedKey} that is used to identify this {@link Category}
|
||||
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
|
||||
* @param item
|
||||
* The {@link ItemStack} that is used to display this {@link Category}
|
||||
* The {@link ItemStack} that is used to display this {@link ItemGroup}
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public Category(NamespacedKey key, ItemStack item) {
|
||||
public ItemGroup(NamespacedKey key, ItemStack item) {
|
||||
this(key, item, 3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Category} with the given {@link NamespacedKey} as an identifier
|
||||
* Constructs a new {@link ItemGroup} with the given {@link NamespacedKey} as an identifier
|
||||
* and the given {@link ItemStack} as its display item.
|
||||
*
|
||||
* @param key
|
||||
* The {@link NamespacedKey} that is used to identify this {@link Category}
|
||||
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
|
||||
* @param item
|
||||
* The {@link ItemStack} that is used to display this {@link Category}
|
||||
* The {@link ItemStack} that is used to display this {@link ItemGroup}
|
||||
* @param tier
|
||||
* The tier of this {@link Category}, higher tiers will make this {@link Category} appear further down in
|
||||
* The tier of this {@link ItemGroup}, higher tiers will make this {@link ItemGroup} appear further down
|
||||
* in
|
||||
* the {@link SlimefunGuide}
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public Category(NamespacedKey key, ItemStack item, int tier) {
|
||||
public ItemGroup(NamespacedKey key, ItemStack item, int tier) {
|
||||
Validate.notNull(key, "A Category's NamespacedKey must not be null!");
|
||||
Validate.notNull(item, "A Category's ItemStack must not be null!");
|
||||
|
||||
@ -100,7 +100,7 @@ public class Category implements Keyed {
|
||||
* By default, a category is automatically registered when a {@link SlimefunItem} was added to it.
|
||||
*
|
||||
* @param addon
|
||||
* The {@link SlimefunAddon} that wants to register this {@link Category}
|
||||
* The {@link SlimefunAddon} that wants to register this {@link ItemGroup}
|
||||
*/
|
||||
public void register(@Nonnull SlimefunAddon addon) {
|
||||
Validate.notNull(addon, "The Addon cannot be null");
|
||||
@ -111,26 +111,26 @@ public class Category implements Keyed {
|
||||
|
||||
this.addon = addon;
|
||||
|
||||
SlimefunPlugin.getRegistry().getCategories().add(this);
|
||||
Slimefun.getRegistry().getAllItemGroups().add(this);
|
||||
sortCategoriesByTier();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tier of this {@link Category}.
|
||||
* The tier determines the position of this {@link Category} in the {@link SlimefunGuide}.
|
||||
* Returns the tier of this {@link ItemGroup}.
|
||||
* The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}.
|
||||
*
|
||||
* @return the tier of this {@link Category}
|
||||
* @return the tier of this {@link ItemGroup}
|
||||
*/
|
||||
public int getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
/**
|
||||
* This sets the tier of this {@link Category}.
|
||||
* The tier determines the position of this {@link Category} in the {@link SlimefunGuide}.
|
||||
* This sets the tier of this {@link ItemGroup}.
|
||||
* The tier determines the position of this {@link ItemGroup} in the {@link SlimefunGuide}.
|
||||
*
|
||||
* @param tier
|
||||
* The tier for this {@link Category}
|
||||
* The tier for this {@link ItemGroup}
|
||||
*/
|
||||
public void setTier(int tier) {
|
||||
this.tier = tier;
|
||||
@ -142,15 +142,15 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* This refreshes the {@link Category} order.
|
||||
* This refreshes the {@link ItemGroup} order.
|
||||
*/
|
||||
private void sortCategoriesByTier() {
|
||||
List<Category> categories = SlimefunPlugin.getRegistry().getCategories();
|
||||
Collections.sort(categories, Comparator.comparingInt(Category::getTier));
|
||||
List<ItemGroup> categories = Slimefun.getRegistry().getAllItemGroups();
|
||||
Collections.sort(categories, Comparator.comparingInt(ItemGroup::getTier));
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the {@link SlimefunAddon} which has registered this {@link Category}.
|
||||
* This returns the {@link SlimefunAddon} which has registered this {@link ItemGroup}.
|
||||
* Or null if it has not been registered yet.
|
||||
*
|
||||
* @return The {@link SlimefunAddon} or null if unregistered
|
||||
@ -161,10 +161,10 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given {@link SlimefunItem} to this {@link Category}.
|
||||
* Adds the given {@link SlimefunItem} to this {@link ItemGroup}.
|
||||
*
|
||||
* @param item
|
||||
* the {@link SlimefunItem} that should be added to this {@link Category}
|
||||
* the {@link SlimefunItem} that should be added to this {@link ItemGroup}
|
||||
*/
|
||||
public void add(@Nonnull SlimefunItem item) {
|
||||
Validate.notNull(item, "Cannot add null Items to a Category!");
|
||||
@ -178,10 +178,10 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the given {@link SlimefunItem} from this {@link Category}.
|
||||
* Removes the given {@link SlimefunItem} from this {@link ItemGroup}.
|
||||
*
|
||||
* @param item
|
||||
* the {@link SlimefunItem} that should be removed from this {@link Category}
|
||||
* the {@link SlimefunItem} that should be removed from this {@link ItemGroup}
|
||||
*/
|
||||
public void remove(@Nonnull SlimefunItem item) {
|
||||
Validate.notNull(item, "Cannot remove null from a Category!");
|
||||
@ -189,38 +189,38 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns a localized display item of this {@link Category}
|
||||
* This method returns a localized display item of this {@link ItemGroup}
|
||||
* for the specified {@link Player}.
|
||||
*
|
||||
* @param p
|
||||
* The Player to create this {@link ItemStack} for
|
||||
*
|
||||
* @return A localized display item for this {@link Category}
|
||||
* @return A localized display item for this {@link ItemGroup}
|
||||
*/
|
||||
@Nonnull
|
||||
public ItemStack getItem(@Nonnull Player p) {
|
||||
return new CustomItem(item, meta -> {
|
||||
String name = SlimefunPlugin.getLocalization().getCategoryName(p, getKey());
|
||||
return new CustomItemStack(item, meta -> {
|
||||
String name = Slimefun.getLocalization().getCategoryName(p, getKey());
|
||||
|
||||
if (name == null) {
|
||||
name = item.getItemMeta().getDisplayName();
|
||||
}
|
||||
|
||||
if (this instanceof SeasonalCategory) {
|
||||
if (this instanceof SeasonalItemGroup) {
|
||||
meta.setDisplayName(ChatColor.GOLD + name);
|
||||
} else {
|
||||
meta.setDisplayName(ChatColor.YELLOW + name);
|
||||
}
|
||||
|
||||
meta.setLore(Arrays.asList("", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + SlimefunPlugin.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
||||
meta.setLore(Arrays.asList("", ChatColor.GRAY + "\u21E8 " + ChatColor.GREEN + Slimefun.getLocalization().getMessage(p, "guide.tooltips.open-category")));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method makes Walshy happy.
|
||||
* It adds a way to get the name of a {@link Category} without localization nor coloring.
|
||||
* It adds a way to get the name of a {@link ItemGroup} without localization nor coloring.
|
||||
*
|
||||
* @return The unlocalized name of this {@link Category}
|
||||
* @return The unlocalized name of this {@link ItemGroup}
|
||||
*/
|
||||
@Nonnull
|
||||
public String getUnlocalizedName() {
|
||||
@ -228,17 +228,17 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the localized display name of this {@link Category} for the given {@link Player}.
|
||||
* This returns the localized display name of this {@link ItemGroup} for the given {@link Player}.
|
||||
* The method will fall back to {@link #getUnlocalizedName()} if no translation was found.
|
||||
*
|
||||
* @param p
|
||||
* The {@link Player} who to translate the name for
|
||||
*
|
||||
* @return The localized name of this {@link Category}
|
||||
* @return The localized name of this {@link ItemGroup}
|
||||
*/
|
||||
@Nonnull
|
||||
public String getDisplayName(@Nonnull Player p) {
|
||||
String localized = SlimefunPlugin.getLocalization().getCategoryName(p, getKey());
|
||||
String localized = Slimefun.getLocalization().getCategoryName(p, getKey());
|
||||
|
||||
if (localized != null) {
|
||||
return localized;
|
||||
@ -248,7 +248,7 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all instances of {@link SlimefunItem} bound to this {@link Category}.
|
||||
* Returns all instances of {@link SlimefunItem} bound to this {@link ItemGroup}.
|
||||
*
|
||||
* @return the list of SlimefunItems bound to this category
|
||||
*/
|
||||
@ -258,12 +258,12 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether a given {@link SlimefunItem} exists in this {@link Category}.
|
||||
* This method returns whether a given {@link SlimefunItem} exists in this {@link ItemGroup}.
|
||||
*
|
||||
* @param item
|
||||
* The {@link SlimefunItem} to find
|
||||
*
|
||||
* @return Whether the given {@link SlimefunItem} was found in this {@link Category}
|
||||
* @return Whether the given {@link SlimefunItem} was found in this {@link ItemGroup}
|
||||
*/
|
||||
public boolean contains(@Nullable SlimefunItem item) {
|
||||
return item != null && items.contains(item);
|
||||
@ -271,8 +271,8 @@ public class Category implements Keyed {
|
||||
|
||||
@Override
|
||||
public final boolean equals(Object obj) {
|
||||
if (obj instanceof Category) {
|
||||
return ((Category) obj).getKey().equals(getKey());
|
||||
if (obj instanceof ItemGroup) {
|
||||
return ((ItemGroup) obj).getKey().equals(getKey());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@ -289,7 +289,7 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method checks whether this {@link Category} will be hidden for the specified
|
||||
* This method checks whether this {@link ItemGroup} will be hidden for the specified
|
||||
* {@link Player}.
|
||||
*
|
||||
* Categories are hidden if all of their items have been disabled.
|
||||
@ -297,7 +297,7 @@ public class Category implements Keyed {
|
||||
* @param p
|
||||
* The {@link Player} to check for
|
||||
*
|
||||
* @return Whether this {@link Category} will be hidden to the given {@link Player}
|
||||
* @return Whether this {@link ItemGroup} will be hidden to the given {@link Player}
|
||||
*/
|
||||
public boolean isHidden(@Nonnull Player p) {
|
||||
for (SlimefunItem slimefunItem : getItems()) {
|
||||
@ -310,13 +310,13 @@ public class Category implements Keyed {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether this {@link Category} has been registered yet.
|
||||
* This method returns whether this {@link ItemGroup} has been registered yet.
|
||||
* More specifically: Whether {@link #register(SlimefunAddon)} was called or not.
|
||||
*
|
||||
* @return Whether this {@link Category} has been registered
|
||||
* @return Whether this {@link ItemGroup} has been registered
|
||||
*/
|
||||
public boolean isRegistered() {
|
||||
return SlimefunPlugin.getRegistry().getCategories().contains(this);
|
||||
return Slimefun.getRegistry().getAllItemGroups().contains(this);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.handlers;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@ -11,7 +11,6 @@ import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityKillHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemConsumptionHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* An {@link ItemHandler} represents a certain action that a {@link SlimefunItem}
|
@ -8,9 +8,8 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* This class represents a Setting for a {@link SlimefunItem} that can be modified via
|
||||
@ -87,8 +86,7 @@ public class ItemSetting<T> {
|
||||
*
|
||||
* @return The key under which this setting is stored (relative to the {@link SlimefunItem})
|
||||
*/
|
||||
@Nonnull
|
||||
public String getKey() {
|
||||
public @Nonnull String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
@ -97,8 +95,7 @@ public class ItemSetting<T> {
|
||||
*
|
||||
* @return The associated {@link SlimefunItem}
|
||||
*/
|
||||
@Nonnull
|
||||
protected SlimefunItem getItem() {
|
||||
protected @Nonnull SlimefunItem getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@ -107,8 +104,7 @@ public class ItemSetting<T> {
|
||||
*
|
||||
* @return The current value
|
||||
*/
|
||||
@Nonnull
|
||||
public T getValue() {
|
||||
public @Nonnull T getValue() {
|
||||
if (value != null) {
|
||||
return value;
|
||||
} else {
|
||||
@ -122,8 +118,7 @@ public class ItemSetting<T> {
|
||||
*
|
||||
* @return The default value
|
||||
*/
|
||||
@Nonnull
|
||||
public T getDefaultValue() {
|
||||
public @Nonnull T getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@ -145,8 +140,7 @@ public class ItemSetting<T> {
|
||||
*
|
||||
* @return An error message which is displayed when this {@link ItemSetting} is misconfigured.
|
||||
*/
|
||||
@Nonnull
|
||||
protected String getErrorMessage() {
|
||||
protected @Nonnull String getErrorMessage() {
|
||||
return "Only '" + defaultValue.getClass().getSimpleName() + "' values are allowed!";
|
||||
}
|
||||
|
||||
@ -159,8 +153,8 @@ public class ItemSetting<T> {
|
||||
public void reload() {
|
||||
Validate.notNull(item, "Cannot apply settings for a non-existing SlimefunItem");
|
||||
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
|
||||
Object configuredValue = SlimefunPlugin.getItemCfg().getValue(item.getId() + '.' + getKey());
|
||||
Slimefun.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
|
||||
Object configuredValue = Slimefun.getItemCfg().getValue(item.getId() + '.' + getKey());
|
||||
|
||||
if (defaultValue.getClass().isInstance(configuredValue) || (configuredValue instanceof List && defaultValue instanceof List)) {
|
||||
// We can do an unsafe cast here, we did an isInstance(...) check before!
|
||||
|
@ -1,7 +1,6 @@
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* Defines whether a SlimefunItem is enabled, disabled or fall-back to its vanilla behavior.
|
||||
@ -32,5 +31,6 @@ public enum ItemState {
|
||||
* This {@link SlimefunItem} has fallen back to its vanilla behavior, because it is disabled and an instance of
|
||||
* {@link VanillaItem}.
|
||||
*/
|
||||
VANILLA_FALLBACK
|
||||
}
|
||||
VANILLA_FALLBACK;
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Objects.SlimefunItem;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
@ -22,8 +22,8 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.Permission;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.OptionalMap;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.bakedlibs.dough.collections.OptionalMap;
|
||||
import io.github.bakedlibs.dough.items.ItemUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunBranch;
|
||||
@ -32,9 +32,9 @@ import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandler
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.MissingDependencyException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.UnregisteredItemException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemState;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.SlimefunRegistry;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Placeable;
|
||||
@ -42,19 +42,15 @@ import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.GlobalItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoDisenchanter;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.enchanting.AutoEnchanter;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
/**
|
||||
* A {@link SlimefunItem} is a custom item registered by a {@link SlimefunAddon}.
|
||||
@ -97,9 +93,9 @@ public class SlimefunItem implements Placeable {
|
||||
private ItemState state = ItemState.UNREGISTERED;
|
||||
|
||||
/**
|
||||
* This is the {@link Category} in which this {@link SlimefunItem} can be found.
|
||||
* This is the {@link ItemGroup} in which this {@link SlimefunItem} can be found.
|
||||
*/
|
||||
private Category category;
|
||||
private ItemGroup itemGroup;
|
||||
|
||||
/**
|
||||
* This is a reference to the associated {@link Research}, can be null.
|
||||
@ -126,8 +122,8 @@ public class SlimefunItem implements Placeable {
|
||||
/**
|
||||
* This creates a new {@link SlimefunItem} from the given arguments.
|
||||
*
|
||||
* @param category
|
||||
* The {@link Category} this {@link SlimefunItem} belongs to
|
||||
* @param itemGroup
|
||||
* The {@link ItemGroup} this {@link SlimefunItem} belongs to
|
||||
* @param item
|
||||
* The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem}
|
||||
* @param recipeType
|
||||
@ -136,15 +132,15 @@ public class SlimefunItem implements Placeable {
|
||||
* An Array representing the recipe of this {@link SlimefunItem}
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public SlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
this(category, item, recipeType, recipe, null);
|
||||
public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
this(itemGroup, item, recipeType, recipe, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* This creates a new {@link SlimefunItem} from the given arguments.
|
||||
*
|
||||
* @param category
|
||||
* The {@link Category} this {@link SlimefunItem} belongs to
|
||||
* @param itemGroup
|
||||
* The {@link ItemGroup} this {@link SlimefunItem} belongs to
|
||||
* @param item
|
||||
* The {@link SlimefunItemStack} that describes the visual features of our {@link SlimefunItem}
|
||||
* @param recipeType
|
||||
@ -155,12 +151,12 @@ public class SlimefunItem implements Placeable {
|
||||
* The result of crafting this item
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public SlimefunItem(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) {
|
||||
Validate.notNull(category, "'category' is not allowed to be null!");
|
||||
public SlimefunItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, @Nullable ItemStack recipeOutput) {
|
||||
Validate.notNull(itemGroup, "'itemGroup' is not allowed to be null!");
|
||||
Validate.notNull(item, "'item' is not allowed to be null!");
|
||||
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
|
||||
|
||||
this.category = category;
|
||||
this.itemGroup = itemGroup;
|
||||
this.itemStackTemplate = item;
|
||||
this.id = item.getItemId();
|
||||
this.recipeType = recipeType;
|
||||
@ -170,13 +166,13 @@ public class SlimefunItem implements Placeable {
|
||||
|
||||
// Previously deprecated constructor, now only for internal purposes
|
||||
@ParametersAreNonnullByDefault
|
||||
protected SlimefunItem(Category category, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
|
||||
Validate.notNull(category, "'category' is not allowed to be null!");
|
||||
protected SlimefunItem(ItemGroup itemGroup, ItemStack item, String id, RecipeType recipeType, ItemStack[] recipe) {
|
||||
Validate.notNull(itemGroup, "'itemGroup' is not allowed to be null!");
|
||||
Validate.notNull(item, "'item' is not allowed to be null!");
|
||||
Validate.notNull(id, "'id' is not allowed to be null!");
|
||||
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
|
||||
|
||||
this.category = category;
|
||||
this.itemGroup = itemGroup;
|
||||
this.itemStackTemplate = item;
|
||||
this.id = id;
|
||||
this.recipeType = recipeType;
|
||||
@ -216,13 +212,13 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns the {@link Category} of our {@link SlimefunItem}, every {@link SlimefunItem}
|
||||
* is associated with exactly one {@link Category}.
|
||||
* This returns the {@link ItemGroup} of our {@link SlimefunItem}, every {@link SlimefunItem}
|
||||
* is associated with exactly one {@link ItemGroup}.
|
||||
*
|
||||
* @return The {@link Category} that this {@link SlimefunItem} belongs to
|
||||
* @return The {@link ItemGroup} that this {@link SlimefunItem} belongs to
|
||||
*/
|
||||
public @Nonnull Category getCategory() {
|
||||
return category;
|
||||
public @Nonnull ItemGroup getItemGroup() {
|
||||
return itemGroup;
|
||||
}
|
||||
|
||||
public @Nonnull ItemStack[] getRecipe() {
|
||||
@ -344,9 +340,9 @@ public class SlimefunItem implements Placeable {
|
||||
|
||||
if (state == ItemState.ENABLED) {
|
||||
if (hidden) {
|
||||
category.remove(this);
|
||||
itemGroup.remove(this);
|
||||
} else {
|
||||
category.add(this);
|
||||
itemGroup.add(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,13 +379,13 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
// Check if the Item is disabled globally or in this specific world
|
||||
return isDisabled() || !SlimefunPlugin.getWorldSettingsService().isEnabled(world, this);
|
||||
return isDisabled() || !Slimefun.getWorldSettingsService().isEnabled(world, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the {@link SlimefunAddon} that registered this
|
||||
* {@link SlimefunItem}. If this Item is from Slimefun itself, the current
|
||||
* instance of {@link SlimefunPlugin} will be returned.
|
||||
* instance of {@link Slimefun} will be returned.
|
||||
* Use an instanceof check to account for that.
|
||||
*
|
||||
* @return The {@link SlimefunAddon} that registered this {@link SlimefunItem}
|
||||
@ -432,16 +428,16 @@ public class SlimefunItem implements Placeable {
|
||||
recipe = Arrays.copyOf(recipe, 9);
|
||||
}
|
||||
|
||||
SlimefunPlugin.getRegistry().getAllSlimefunItems().add(this);
|
||||
SlimefunPlugin.getRegistry().getSlimefunItemIds().put(id, this);
|
||||
Slimefun.getRegistry().getAllSlimefunItems().add(this);
|
||||
Slimefun.getRegistry().getSlimefunItemIds().put(id, this);
|
||||
|
||||
// Items that are "not-configurable" cannot be configured.
|
||||
if (!(this instanceof NotConfigurable)) {
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".enabled", true);
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".can-be-used-in-workbenches", useableInWorkbench);
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".hide-in-guide", hidden);
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-enchanting", enchantable);
|
||||
SlimefunPlugin.getItemCfg().setDefaultValue(id + ".allow-disenchanting", disenchantable);
|
||||
Slimefun.getItemCfg().setDefaultValue(id + ".enabled", true);
|
||||
Slimefun.getItemCfg().setDefaultValue(id + ".can-be-used-in-workbenches", useableInWorkbench);
|
||||
Slimefun.getItemCfg().setDefaultValue(id + ".hide-in-guide", hidden);
|
||||
Slimefun.getItemCfg().setDefaultValue(id + ".allow-enchanting", enchantable);
|
||||
Slimefun.getItemCfg().setDefaultValue(id + ".allow-disenchanting", disenchantable);
|
||||
|
||||
// Load all item settings
|
||||
for (ItemSetting<?> setting : itemSettings) {
|
||||
@ -449,7 +445,7 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
}
|
||||
|
||||
if (ticking && !SlimefunPlugin.getCfg().getBoolean("URID.enable-tickers")) {
|
||||
if (ticking && !Slimefun.getCfg().getBoolean("URID.enable-tickers")) {
|
||||
state = ItemState.DISABLED;
|
||||
return;
|
||||
}
|
||||
@ -460,13 +456,13 @@ public class SlimefunItem implements Placeable {
|
||||
* Any other settings will remain as default.
|
||||
*/
|
||||
state = ItemState.ENABLED;
|
||||
} else if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) {
|
||||
} else if (Slimefun.getItemCfg().getBoolean(id + ".enabled")) {
|
||||
// The item has been 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");
|
||||
useableInWorkbench = Slimefun.getItemCfg().getBoolean(id + ".can-be-used-in-workbenches");
|
||||
hidden = Slimefun.getItemCfg().getBoolean(id + ".hide-in-guide");
|
||||
enchantable = Slimefun.getItemCfg().getBoolean(id + ".allow-enchanting");
|
||||
disenchantable = Slimefun.getItemCfg().getBoolean(id + ".allow-disenchanting");
|
||||
} else if (this instanceof VanillaItem) {
|
||||
// This item is a vanilla "mock" but was disabled.
|
||||
state = ItemState.VANILLA_FALLBACK;
|
||||
@ -488,7 +484,7 @@ public class SlimefunItem implements Placeable {
|
||||
postRegister();
|
||||
|
||||
// handle runtime-registrations / auto-loading
|
||||
if (SlimefunPlugin.getRegistry().isAutoLoadingEnabled() && state == ItemState.ENABLED) {
|
||||
if (Slimefun.getRegistry().isAutoLoadingEnabled() && state == ItemState.ENABLED) {
|
||||
info("Item was registered during runtime.");
|
||||
load();
|
||||
}
|
||||
@ -501,12 +497,12 @@ public class SlimefunItem implements Placeable {
|
||||
* This method is called when this {@link SlimefunItem} is currently being registered
|
||||
* and we are certain that it will be enabled.
|
||||
*
|
||||
* <strong>This method is for internal purposes, like {@link Category} registration only</strong>
|
||||
* <strong>This method is for internal purposes, like {@link ItemGroup} registration only</strong>
|
||||
*/
|
||||
private final void onEnable() {
|
||||
// Register the Category too if it hasn't been registered yet
|
||||
if (!category.isRegistered()) {
|
||||
category.register(addon);
|
||||
if (!itemGroup.isRegistered()) {
|
||||
itemGroup.register(addon);
|
||||
}
|
||||
|
||||
// Send out deprecation warnings for any classes or interfaces
|
||||
@ -523,14 +519,14 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
// Add it to the list of enabled items
|
||||
SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this);
|
||||
Slimefun.getRegistry().getEnabledSlimefunItems().add(this);
|
||||
|
||||
// Load our Item Handlers
|
||||
loadItemHandlers();
|
||||
|
||||
// Properly mark this Item as radioactive
|
||||
if (this instanceof Radioactive) {
|
||||
SlimefunPlugin.getRegistry().getRadioactiveItems().add(this);
|
||||
Slimefun.getRegistry().getRadioactiveItems().add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@ -554,7 +550,7 @@ public class SlimefunItem implements Placeable {
|
||||
* we add it to the list of global Item handlers
|
||||
*/
|
||||
if (handler instanceof GlobalItemHandler) {
|
||||
SlimefunRegistry registry = SlimefunPlugin.getRegistry();
|
||||
SlimefunRegistry registry = Slimefun.getRegistry();
|
||||
registry.getGlobalItemHandlers(handler.getIdentifier()).add(handler);
|
||||
}
|
||||
}
|
||||
@ -590,7 +586,7 @@ public class SlimefunItem implements Placeable {
|
||||
* This method checks for id conflicts.
|
||||
*/
|
||||
private void checkForConflicts() {
|
||||
SlimefunItem conflictingItem = getByID(id);
|
||||
SlimefunItem conflictingItem = getById(id);
|
||||
|
||||
if (conflictingItem != null) {
|
||||
throw new IdConflictException(this, conflictingItem);
|
||||
@ -607,7 +603,7 @@ public class SlimefunItem implements Placeable {
|
||||
* The {@link Class} from which to start this operation.
|
||||
*/
|
||||
private void checkForDeprecations(@Nullable Class<?> c) {
|
||||
if (SlimefunPlugin.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) {
|
||||
if (Slimefun.getUpdater().getBranch() == SlimefunBranch.DEVELOPMENT) {
|
||||
/*
|
||||
* This method is currently way too spammy with all the restructuring going on...
|
||||
* Since DEV builds are anyway under "development", things may be relocated.
|
||||
@ -673,18 +669,18 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* This sets the {@link Category} in which this {@link SlimefunItem} will be displayed.
|
||||
* This sets the {@link ItemGroup} in which this {@link SlimefunItem} will be displayed.
|
||||
*
|
||||
* @param category
|
||||
* The new {@link Category}
|
||||
* The new {@link ItemGroup}
|
||||
*/
|
||||
public void setCategory(@Nonnull Category category) {
|
||||
public void setItemGroup(@Nonnull ItemGroup category) {
|
||||
Validate.notNull(category, "The Category is not allowed to be null!");
|
||||
|
||||
this.category.remove(this);
|
||||
this.itemGroup.remove(this);
|
||||
category.add(this);
|
||||
|
||||
this.category = category;
|
||||
this.itemGroup = category;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -747,7 +743,7 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
if (item.hasItemMeta()) {
|
||||
Optional<String> itemId = SlimefunPlugin.getItemDataService().getItemData(item);
|
||||
Optional<String> itemId = Slimefun.getItemDataService().getItemData(item);
|
||||
|
||||
if (itemId.isPresent()) {
|
||||
return getId().equals(itemId.get());
|
||||
@ -755,7 +751,7 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
// Backwards compatibility
|
||||
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
|
||||
if (Slimefun.getRegistry().isBackwardsCompatible()) {
|
||||
boolean loreInsensitive = this instanceof Rechargeable || this instanceof SlimefunBackpack || id.equals("BROKEN_SPAWNER") || id.equals("REINFORCED_SPAWNER");
|
||||
return SlimefunUtils.isItemSimilar(item, this.itemStackTemplate, !loreInsensitive);
|
||||
} else {
|
||||
@ -768,7 +764,7 @@ public class SlimefunItem implements Placeable {
|
||||
*/
|
||||
public void load() {
|
||||
if (!hidden) {
|
||||
category.add(this);
|
||||
itemGroup.add(this);
|
||||
}
|
||||
|
||||
recipeType.register(recipe, getRecipeOutput());
|
||||
@ -796,7 +792,7 @@ public class SlimefunItem implements Placeable {
|
||||
// Tickers are a special case (at the moment at least)
|
||||
if (handler instanceof BlockTicker) {
|
||||
ticking = true;
|
||||
SlimefunPlugin.getRegistry().getTickerBlocks().add(getId());
|
||||
Slimefun.getRegistry().getTickerBlocks().add(getId());
|
||||
blockTicker = (BlockTicker) handler;
|
||||
}
|
||||
}
|
||||
@ -887,7 +883,7 @@ public class SlimefunItem implements Placeable {
|
||||
*/
|
||||
public final @Nonnull String getItemName() {
|
||||
if (itemStackTemplate instanceof SlimefunItemStack) {
|
||||
Optional<String> name = ((SlimefunItemStack) itemStackTemplate).getImmutableMeta().getDisplayName();
|
||||
Optional<String> name = ((SlimefunItemStack) itemStackTemplate).getItemMetaSnapshot().getDisplayName();
|
||||
|
||||
if (name.isPresent()) {
|
||||
return name.get();
|
||||
@ -1020,7 +1016,7 @@ public class SlimefunItem implements Placeable {
|
||||
addon.getLogger().log(Level.SEVERE, message, throwable);
|
||||
|
||||
// We definitely want to re-throw them during Unit Tests
|
||||
if (throwable instanceof RuntimeException && SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
|
||||
if (throwable instanceof RuntimeException && Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
|
||||
throw (RuntimeException) throwable;
|
||||
}
|
||||
}
|
||||
@ -1055,21 +1051,21 @@ public class SlimefunItem implements Placeable {
|
||||
} else if (isDisabled()) {
|
||||
// The Item has been disabled in the config
|
||||
if (sendMessage) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-item", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.disabled-item", true);
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (!SlimefunPlugin.getWorldSettingsService().isEnabled(p.getWorld(), this)) {
|
||||
} else if (!Slimefun.getWorldSettingsService().isEnabled(p.getWorld(), this)) {
|
||||
// The Item was disabled in the current World
|
||||
if (sendMessage) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.disabled-in-world", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.disabled-in-world", true);
|
||||
}
|
||||
|
||||
return false;
|
||||
} else if (!SlimefunPlugin.getPermissionsService().hasPermission(p, this)) {
|
||||
} else if (!Slimefun.getPermissionsService().hasPermission(p, this)) {
|
||||
// The Player does not have the required permission node
|
||||
if (sendMessage) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.no-permission", true);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1090,7 +1086,7 @@ public class SlimefunItem implements Placeable {
|
||||
* required Research to use this SlimefunItem.
|
||||
*/
|
||||
if (sendMessage && !(this instanceof VanillaItem)) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.not-researched", true, s -> s.replace("%item%", getItemName()));
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.not-researched", true, s -> s.replace("%item%", getItemName()));
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -1121,8 +1117,8 @@ public class SlimefunItem implements Placeable {
|
||||
return getId().hashCode();
|
||||
}
|
||||
|
||||
public static @Nullable SlimefunItem getByID(@Nonnull String id) {
|
||||
return SlimefunPlugin.getRegistry().getSlimefunItemIds().get(id);
|
||||
public static @Nullable SlimefunItem getById(@Nonnull String id) {
|
||||
return Slimefun.getRegistry().getSlimefunItemIds().get(id);
|
||||
}
|
||||
|
||||
public static @Nullable SlimefunItem getByItem(@Nullable ItemStack item) {
|
||||
@ -1131,17 +1127,17 @@ public class SlimefunItem implements Placeable {
|
||||
}
|
||||
|
||||
if (item instanceof SlimefunItemStack) {
|
||||
return getByID(((SlimefunItemStack) item).getItemId());
|
||||
return getById(((SlimefunItemStack) item).getItemId());
|
||||
}
|
||||
|
||||
Optional<String> itemID = SlimefunPlugin.getItemDataService().getItemData(item);
|
||||
Optional<String> itemID = Slimefun.getItemDataService().getItemData(item);
|
||||
|
||||
if (itemID.isPresent()) {
|
||||
return getByID(itemID.get());
|
||||
return getById(itemID.get());
|
||||
}
|
||||
|
||||
// Backwards compatibility
|
||||
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
|
||||
if (Slimefun.getRegistry().isBackwardsCompatible()) {
|
||||
// This wrapper improves the heavy ItemStack#getItemMeta() call by caching it.
|
||||
ItemStackWrapper wrapper = ItemStackWrapper.wrap(item);
|
||||
|
||||
@ -1149,13 +1145,13 @@ public class SlimefunItem implements Placeable {
|
||||
* Quite expensive performance-wise.
|
||||
* But necessary for supporting legacy items
|
||||
*/
|
||||
for (SlimefunItem sfi : SlimefunPlugin.getRegistry().getAllSlimefunItems()) {
|
||||
for (SlimefunItem sfi : Slimefun.getRegistry().getAllSlimefunItems()) {
|
||||
if (sfi.isItem(wrapper)) {
|
||||
/*
|
||||
* If we have to loop all items for the given item, then at least
|
||||
* set the id via PersistentDataAPI for future performance boosts
|
||||
*/
|
||||
SlimefunPlugin.getItemDataService().setItemData(item, sfi.getId());
|
||||
Slimefun.getItemDataService().setItemData(item, sfi.getId());
|
||||
|
||||
return sfi;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.api;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
@ -18,43 +18,128 @@ import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
import org.bukkit.inventory.meta.PotionMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.ImmutableItemMeta;
|
||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.ItemMetaSnapshot;
|
||||
import io.github.bakedlibs.dough.skins.PlayerHead;
|
||||
import io.github.bakedlibs.dough.skins.PlayerSkin;
|
||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.PrematureCodeException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.WrongItemStackException;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
public class SlimefunItemStack extends CustomItem {
|
||||
/**
|
||||
* The {@link SlimefunItemStack} functions as the base for any
|
||||
* {@link SlimefunItem}.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
* @author Walshy
|
||||
*
|
||||
*/
|
||||
public class SlimefunItemStack extends ItemStack {
|
||||
|
||||
private String id;
|
||||
private ImmutableItemMeta immutableMeta;
|
||||
private ItemMetaSnapshot itemMetaSnapshot;
|
||||
|
||||
private boolean locked = false;
|
||||
private String texture = null;
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, String... lore) {
|
||||
super(type, name, lore);
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item) {
|
||||
super(item);
|
||||
|
||||
setItemId(id);
|
||||
Validate.notNull(id, "The Item id must never be null!");
|
||||
Validate.isTrue(id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')");
|
||||
|
||||
if (Slimefun.instance() == null) {
|
||||
throw new PrematureCodeException("A SlimefunItemStack must never be be created before your Plugin was enabled.");
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
|
||||
ItemMeta meta = getItemMeta();
|
||||
|
||||
Slimefun.getItemDataService().setItemData(meta, id);
|
||||
Slimefun.getItemTextureService().setTexture(meta, id);
|
||||
|
||||
setItemMeta(meta);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
this(id, item);
|
||||
|
||||
ItemMeta im = getItemMeta();
|
||||
consumer.accept(im);
|
||||
setItemMeta(im);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
this(id, new ItemStack(type), consumer);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
this(id, type, meta -> {
|
||||
if (name != null) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
}
|
||||
|
||||
consumer.accept(meta);
|
||||
});
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nullable String name, String... lore) {
|
||||
this(id, item, im -> {
|
||||
if (name != null) {
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
}
|
||||
|
||||
if (lore.length > 0) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
for (String line : lore) {
|
||||
lines.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
im.setLore(lines);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, String... lore) {
|
||||
this(id, new ItemStack(type), name, lore);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nonnull Color color, @Nullable String name, String... lore) {
|
||||
super(new ItemStack(type), color, name, lore);
|
||||
this(id, type, im -> {
|
||||
if (name != null) {
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
}
|
||||
|
||||
setItemId(id);
|
||||
if (lore.length > 0) {
|
||||
List<String> lines = new ArrayList<>();
|
||||
|
||||
for (String line : lore) {
|
||||
lines.add(ChatColor.translateAlternateColorCodes('&', line));
|
||||
}
|
||||
|
||||
im.setLore(lines);
|
||||
}
|
||||
|
||||
if (im instanceof LeatherArmorMeta) {
|
||||
((LeatherArmorMeta) im).setColor(color);
|
||||
}
|
||||
|
||||
if (im instanceof PotionMeta) {
|
||||
((PotionMeta) im).setColor(color);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Color color, @Nonnull PotionEffect effect, @Nullable String name, String... lore) {
|
||||
super(Material.POTION, im -> {
|
||||
this(id, Material.POTION, im -> {
|
||||
if (name != null) {
|
||||
im.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
}
|
||||
@ -78,20 +163,6 @@ public class SlimefunItemStack extends CustomItem {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nullable String name, String... lore) {
|
||||
super(item, name, lore);
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item) {
|
||||
super(item);
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull SlimefunItemStack item, int amount) {
|
||||
@ -99,29 +170,9 @@ public class SlimefunItemStack extends CustomItem {
|
||||
setAmount(amount);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull ItemStack item, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
super(item, consumer);
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull Material type, @Nullable String name, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
super(type, meta -> {
|
||||
if (name != null) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
}
|
||||
|
||||
consumer.accept(meta);
|
||||
});
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nullable String name, String... lore) {
|
||||
super(getSkull(id, texture), name, lore);
|
||||
this(id, getSkull(id, texture), name, lore);
|
||||
this.texture = getTexture(id, texture);
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull HeadTexture head, @Nullable String name, String... lore) {
|
||||
@ -129,7 +180,7 @@ public class SlimefunItemStack extends CustomItem {
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nullable String name, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
super(getSkull(id, texture), meta -> {
|
||||
this(id, getSkull(id, texture), meta -> {
|
||||
if (name != null) {
|
||||
meta.setDisplayName(ChatColor.translateAlternateColorCodes('&', name));
|
||||
}
|
||||
@ -138,33 +189,11 @@ public class SlimefunItemStack extends CustomItem {
|
||||
});
|
||||
|
||||
this.texture = getTexture(id, texture);
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
public SlimefunItemStack(@Nonnull String id, @Nonnull String texture, @Nonnull Consumer<ItemMeta> consumer) {
|
||||
super(getSkull(id, texture), consumer);
|
||||
this(id, getSkull(id, texture), consumer);
|
||||
this.texture = getTexture(id, texture);
|
||||
|
||||
setItemId(id);
|
||||
}
|
||||
|
||||
private void setItemId(@Nonnull String id) {
|
||||
Validate.notNull(id, "The Item id must never be null!");
|
||||
Validate.isTrue(id.equals(id.toUpperCase(Locale.ROOT)), "Slimefun Item Ids must be uppercase! (e.g. 'MY_ITEM_ID')");
|
||||
|
||||
if (SlimefunPlugin.instance() == null) {
|
||||
throw new PrematureCodeException("A SlimefunItemStack must never be be created before your Plugin was enabled.");
|
||||
}
|
||||
|
||||
this.id = id;
|
||||
|
||||
ItemMeta meta = getItemMeta();
|
||||
|
||||
SlimefunPlugin.getItemDataService().setItemData(meta, id);
|
||||
SlimefunPlugin.getItemTextureService().setTexture(meta, id);
|
||||
|
||||
setItemMeta(meta);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -183,7 +212,7 @@ public class SlimefunItemStack extends CustomItem {
|
||||
* @return The {@link SlimefunItem} for this {@link SlimefunItemStack}, null if not found.
|
||||
*/
|
||||
public @Nullable SlimefunItem getItem() {
|
||||
return SlimefunItem.getByID(id);
|
||||
return SlimefunItem.getById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -206,14 +235,14 @@ public class SlimefunItemStack extends CustomItem {
|
||||
return type.isInstance(item) ? type.cast(item) : null;
|
||||
}
|
||||
|
||||
public @Nonnull ImmutableItemMeta getImmutableMeta() {
|
||||
return immutableMeta;
|
||||
public @Nonnull ItemMetaSnapshot getItemMetaSnapshot() {
|
||||
return itemMetaSnapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setItemMeta(ItemMeta meta) {
|
||||
validate();
|
||||
immutableMeta = new ImmutableItemMeta(meta);
|
||||
itemMetaSnapshot = new ItemMetaSnapshot(meta);
|
||||
|
||||
return super.setItemMeta(meta);
|
||||
}
|
||||
@ -245,20 +274,21 @@ public class SlimefunItemStack extends CustomItem {
|
||||
}
|
||||
|
||||
public @Nullable String getDisplayName() {
|
||||
if (immutableMeta == null) {
|
||||
if (itemMetaSnapshot == null) {
|
||||
// Just to be extra safe
|
||||
return null;
|
||||
}
|
||||
|
||||
return immutableMeta.getDisplayName().orElse(null);
|
||||
return itemMetaSnapshot.getDisplayName().orElse(null);
|
||||
}
|
||||
|
||||
private static @Nonnull ItemStack getSkull(@Nonnull String id, @Nonnull String texture) {
|
||||
if (SlimefunPlugin.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
|
||||
if (Slimefun.getMinecraftVersion() == MinecraftVersion.UNIT_TEST) {
|
||||
return new ItemStack(Material.PLAYER_HEAD);
|
||||
}
|
||||
|
||||
return SkullItem.fromBase64(getTexture(id, texture));
|
||||
PlayerSkin skin = PlayerSkin.fromBase64(getTexture(id, texture));
|
||||
return PlayerHead.getItemStack(skin);
|
||||
}
|
||||
|
||||
private static @Nonnull String getTexture(@Nonnull String id, @Nonnull String texture) {
|
||||
@ -267,7 +297,7 @@ public class SlimefunItemStack extends CustomItem {
|
||||
|
||||
if (texture.startsWith("ey")) {
|
||||
return texture;
|
||||
} else if (PatternUtils.HEXADECIMAL.matcher(texture).matches()) {
|
||||
} else if (CommonPatterns.HEXADECIMAL.matcher(texture).matches()) {
|
||||
String value = "{\"textures\":{\"SKIN\":{\"url\":\"http://textures.minecraft.net/texture/" + texture + "\"}}}";
|
||||
return Base64.getEncoder().encodeToString(value.getBytes(StandardCharsets.UTF_8));
|
||||
} else {
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.categories;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items.groups;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -9,14 +9,14 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* A {@link FlexCategory} is a {@link Category} inside the {@link SlimefunGuide} that can
|
||||
* A {@link FlexItemGroup} is a {@link ItemGroup} inside the {@link SlimefunGuide} that can
|
||||
* be completely modified.
|
||||
* It cannot hold any {@link SlimefunItem} but can be completely overridden
|
||||
* to perform any action upon being opened.
|
||||
@ -24,20 +24,20 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
*/
|
||||
public abstract class FlexCategory extends Category {
|
||||
public abstract class FlexItemGroup extends ItemGroup {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
protected FlexCategory(NamespacedKey key, ItemStack item) {
|
||||
protected FlexItemGroup(NamespacedKey key, ItemStack item) {
|
||||
this(key, item, 3);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
protected FlexCategory(NamespacedKey key, ItemStack item, int tier) {
|
||||
protected FlexItemGroup(NamespacedKey key, ItemStack item, int tier) {
|
||||
super(key, item, tier);
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns whether this {@link FlexCategory} is visible under the given context.
|
||||
* This method returns whether this {@link FlexItemGroup} is visible under the given context.
|
||||
* Implementing this method gives full flexibility over who can see the Category when and where.
|
||||
*
|
||||
* @param p
|
||||
@ -45,20 +45,20 @@ public abstract class FlexCategory extends Category {
|
||||
* @param profile
|
||||
* The {@link PlayerProfile} of the {@link Player}
|
||||
* @param layout
|
||||
* The {@link SlimefunGuideMode} in which this {@link FlexCategory} is viewed
|
||||
* The {@link SlimefunGuideMode} in which this {@link FlexItemGroup} is viewed
|
||||
*
|
||||
* @return Whether to display this {@link FlexCategory}
|
||||
* @return Whether to display this {@link FlexItemGroup}
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public abstract boolean isVisible(Player p, PlayerProfile profile, SlimefunGuideMode layout);
|
||||
|
||||
/**
|
||||
* This method is called when a {@link Player} opens this {@link FlexCategory}.
|
||||
* This method is called when a {@link Player} opens this {@link FlexItemGroup}.
|
||||
* This is an abstract method which needs to be implemented in order to determine what this
|
||||
* {@link FlexCategory} should actually do as it cannot hold any items.
|
||||
* {@link FlexItemGroup} should actually do as it cannot hold any items.
|
||||
*
|
||||
* @param p
|
||||
* The {@link Player} who wants to open this {@link FlexCategory}
|
||||
* The {@link Player} who wants to open this {@link FlexItemGroup}
|
||||
* @param profile
|
||||
* The corresponding {@link PlayerProfile} for that {@link Player}
|
||||
* @param layout
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.categories;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items.groups;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
@ -15,31 +15,31 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* Represents a {@link Category} that cannot be opened until the parent category/categories
|
||||
* Represents a {@link ItemGroup} that cannot be opened until the parent category/categories
|
||||
* are fully unlocked.
|
||||
* <p>
|
||||
* See {@link Category} for the complete documentation.
|
||||
* See {@link ItemGroup} for the complete documentation.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see Category
|
||||
* @see SeasonalCategory
|
||||
* @see ItemGroup
|
||||
* @see SeasonalItemGroup
|
||||
*
|
||||
*/
|
||||
public class LockedCategory extends Category {
|
||||
public class LockedItemGroup extends ItemGroup {
|
||||
|
||||
private final NamespacedKey[] keys;
|
||||
private final Set<Category> parents = new HashSet<>();
|
||||
private final Set<ItemGroup> parents = new HashSet<>();
|
||||
|
||||
/**
|
||||
* The basic constructor for a LockedCategory.
|
||||
* Like {@link Category}, the default tier is automatically set to 3.
|
||||
* Like {@link ItemGroup}, the default tier is automatically set to 3.
|
||||
*
|
||||
* @param key
|
||||
* A unique identifier for this category
|
||||
@ -50,7 +50,7 @@ public class LockedCategory extends Category {
|
||||
*
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public LockedCategory(NamespacedKey key, ItemStack item, NamespacedKey... parents) {
|
||||
public LockedItemGroup(NamespacedKey key, ItemStack item, NamespacedKey... parents) {
|
||||
this(key, item, 3, parents);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ public class LockedCategory extends Category {
|
||||
*
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public LockedCategory(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) {
|
||||
public LockedItemGroup(NamespacedKey key, ItemStack item, int tier, NamespacedKey... parents) {
|
||||
super(key, item, tier);
|
||||
Validate.noNullElements(parents, "A LockedCategory must not have any 'null' parents!");
|
||||
|
||||
@ -87,40 +87,40 @@ public class LockedCategory extends Category {
|
||||
}
|
||||
}
|
||||
|
||||
for (Category category : SlimefunPlugin.getRegistry().getCategories()) {
|
||||
for (ItemGroup category : Slimefun.getRegistry().getAllItemGroups()) {
|
||||
if (namespacedKeys.remove(category.getKey())) {
|
||||
addParent(category);
|
||||
}
|
||||
}
|
||||
|
||||
for (NamespacedKey key : namespacedKeys) {
|
||||
SlimefunPlugin.logger().log(Level.INFO, "Parent \"{0}\" for Category \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() });
|
||||
Slimefun.logger().log(Level.INFO, "Parent \"{0}\" for Category \"{1}\" was not found, probably just disabled.", new Object[] { key, getKey() });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of parent categories for this {@link LockedCategory}.
|
||||
* Gets the list of parent categories for this {@link LockedItemGroup}.
|
||||
*
|
||||
* @return the list of parent categories
|
||||
*
|
||||
* @see #addParent(Category)
|
||||
* @see #removeParent(Category)
|
||||
* @see #addParent(ItemGroup)
|
||||
* @see #removeParent(ItemGroup)
|
||||
*/
|
||||
@Nonnull
|
||||
public Set<Category> getParents() {
|
||||
public Set<ItemGroup> getParents() {
|
||||
return parents;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a parent {@link Category} to this {@link LockedCategory}.
|
||||
* Adds a parent {@link ItemGroup} to this {@link LockedItemGroup}.
|
||||
*
|
||||
* @param category
|
||||
* The {@link Category} to add as a parent
|
||||
* The {@link ItemGroup} to add as a parent
|
||||
*
|
||||
* @see #getParents()
|
||||
* @see #removeParent(Category)
|
||||
* @see #removeParent(ItemGroup)
|
||||
*/
|
||||
public void addParent(Category category) {
|
||||
public void addParent(ItemGroup category) {
|
||||
if (category == this || category == null) {
|
||||
throw new IllegalArgumentException("Category '" + item.getItemMeta().getDisplayName() + "' cannot be a parent of itself or have a 'null' parent.");
|
||||
}
|
||||
@ -129,15 +129,15 @@ public class LockedCategory extends Category {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a {@link Category} from the parents of this {@link LockedCategory}.
|
||||
* Removes a {@link ItemGroup} from the parents of this {@link LockedItemGroup}.
|
||||
*
|
||||
* @param category
|
||||
* The {@link Category} to remove from the parents of this {@link LockedCategory}
|
||||
* The {@link ItemGroup} to remove from the parents of this {@link LockedItemGroup}
|
||||
*
|
||||
* @see #getParents()
|
||||
* @see #addParent(Category)
|
||||
* @see #addParent(ItemGroup)
|
||||
*/
|
||||
public void removeParent(@Nonnull Category category) {
|
||||
public void removeParent(@Nonnull ItemGroup category) {
|
||||
parents.remove(category);
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ public class LockedCategory extends Category {
|
||||
Validate.notNull(p, "The player cannot be null!");
|
||||
Validate.notNull(profile, "The Profile cannot be null!");
|
||||
|
||||
for (Category category : parents) {
|
||||
for (ItemGroup category : parents) {
|
||||
for (SlimefunItem item : category.getItems()) {
|
||||
// Check if the Player has researched every item (if the item is enabled)
|
||||
if (!item.isDisabledIn(p.getWorld()) && item.hasResearch() && !profile.hasUnlocked(item.getResearch())) {
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.categories;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items.groups;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -12,53 +12,54 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
public class MultiCategory extends FlexCategory {
|
||||
public class NestedItemGroup extends FlexItemGroup {
|
||||
|
||||
private static final int CATEGORY_SIZE = 36;
|
||||
private final List<SubCategory> subCategories = new ArrayList<>();
|
||||
private static final int GROUP_SIZE = 36;
|
||||
private final List<SubItemGroup> subGroups = new ArrayList<>();
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public MultiCategory(NamespacedKey key, ItemStack item) {
|
||||
public NestedItemGroup(NamespacedKey key, ItemStack item) {
|
||||
this(key, item, 3);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public MultiCategory(NamespacedKey key, ItemStack item, int tier) {
|
||||
public NestedItemGroup(NamespacedKey key, ItemStack item, int tier) {
|
||||
super(key, item, tier);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add the given {@link SubCategory} to this {@link MultiCategory}.
|
||||
* This will add the given {@link SubItemGroup} to this {@link NestedItemGroup}.
|
||||
*
|
||||
* @param category
|
||||
* The {@link SubCategory} to add.
|
||||
* The {@link SubItemGroup} to add.
|
||||
*/
|
||||
public void addSubCategory(@Nonnull SubCategory category) {
|
||||
Validate.notNull(category, "The Category cannot be null!");
|
||||
public void addSubGroup(@Nonnull SubItemGroup category) {
|
||||
Validate.notNull(category, "The sub item group cannot be null!");
|
||||
|
||||
subCategories.add(category);
|
||||
subGroups.add(category);
|
||||
}
|
||||
|
||||
/**
|
||||
* This will remove the given {@link SubCategory} from this {@link MultiCategory} (if present).
|
||||
* This will remove the given {@link SubItemGroup} from this {@link NestedItemGroup} (if present).
|
||||
*
|
||||
* @param category
|
||||
* The {@link SubCategory} to remove.
|
||||
* The {@link SubItemGroup} to remove.
|
||||
*/
|
||||
public void removeSubCategory(@Nonnull SubCategory category) {
|
||||
Validate.notNull(category, "The Category cannot be null!");
|
||||
public void removeSubGroup(@Nonnull SubItemGroup category) {
|
||||
Validate.notNull(category, "The sub item group cannot be null!");
|
||||
|
||||
subCategories.remove(category);
|
||||
subGroups.remove(category);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -81,14 +82,14 @@ public class MultiCategory extends FlexCategory {
|
||||
history.add(this, page);
|
||||
}
|
||||
|
||||
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.main"));
|
||||
SurvivalSlimefunGuide guide = (SurvivalSlimefunGuide) SlimefunPlugin.getRegistry().getSlimefunGuide(mode);
|
||||
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.main"));
|
||||
SurvivalSlimefunGuide guide = (SurvivalSlimefunGuide) Slimefun.getRegistry().getSlimefunGuide(mode);
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), guide.getSound(), 1, 1));
|
||||
guide.createHeader(p, profile, menu);
|
||||
|
||||
menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.guide"))));
|
||||
menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", ChatColor.GRAY + Slimefun.getLocalization().getMessage(p, "guide.back.guide"))));
|
||||
menu.addMenuClickHandler(1, (pl, s, is, action) -> {
|
||||
SlimefunGuide.openMainMenu(profile, mode, history.getMainMenuPage());
|
||||
return false;
|
||||
@ -96,12 +97,12 @@ public class MultiCategory extends FlexCategory {
|
||||
|
||||
int index = 9;
|
||||
|
||||
int target = (CATEGORY_SIZE * (page - 1)) - 1;
|
||||
int target = (GROUP_SIZE * (page - 1)) - 1;
|
||||
|
||||
while (target < (subCategories.size() - 1) && index < CATEGORY_SIZE + 9) {
|
||||
while (target < (subGroups.size() - 1) && index < GROUP_SIZE + 9) {
|
||||
target++;
|
||||
|
||||
SubCategory category = subCategories.get(target);
|
||||
SubItemGroup category = subGroups.get(target);
|
||||
menu.addItem(index, category.getItem(p));
|
||||
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
|
||||
SlimefunGuide.openCategory(profile, category, mode, 1);
|
||||
@ -111,7 +112,7 @@ public class MultiCategory extends FlexCategory {
|
||||
index++;
|
||||
}
|
||||
|
||||
int pages = target == subCategories.size() - 1 ? page : (subCategories.size() - 1) / CATEGORY_SIZE + 1;
|
||||
int pages = target == subGroups.size() - 1 ? page : (subGroups.size() - 1) / GROUP_SIZE + 1;
|
||||
|
||||
menu.addItem(46, ChestMenuUtils.getPreviousButton(p, page, pages));
|
||||
menu.addMenuClickHandler(46, (pl, slot, item, action) -> {
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.categories;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items.groups;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.Month;
|
||||
@ -11,26 +11,26 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
|
||||
/**
|
||||
* Represents a {@link Category} that is only displayed in the Guide during
|
||||
* Represents a {@link ItemGroup} that is only displayed in the Guide during
|
||||
* a specified {@link Month}.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see Category
|
||||
* @see LockedCategory
|
||||
* @see ItemGroup
|
||||
* @see LockedItemGroup
|
||||
*/
|
||||
public class SeasonalCategory extends Category {
|
||||
public class SeasonalItemGroup extends ItemGroup {
|
||||
|
||||
private final Month month;
|
||||
|
||||
/**
|
||||
* The constructor for a {@link SeasonalCategory}.
|
||||
* The constructor for a {@link SeasonalItemGroup}.
|
||||
*
|
||||
* @param key
|
||||
* The {@link NamespacedKey} that is used to identify this {@link Category}
|
||||
* The {@link NamespacedKey} that is used to identify this {@link ItemGroup}
|
||||
* @param month
|
||||
* The month when the category should be displayed (from 1 = January ; to 12 = December)
|
||||
* @param tier
|
||||
@ -39,7 +39,7 @@ public class SeasonalCategory extends Category {
|
||||
* The display item for this category
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public SeasonalCategory(NamespacedKey key, Month month, int tier, ItemStack item) {
|
||||
public SeasonalItemGroup(NamespacedKey key, Month month, int tier, ItemStack item) {
|
||||
super(key, item, tier);
|
||||
Validate.notNull(month, "The Month cannot be null");
|
||||
|
||||
@ -47,9 +47,9 @@ public class SeasonalCategory extends Category {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns the {@link Month} in which this {@link SeasonalCategory} will appear.
|
||||
* This method returns the {@link Month} in which this {@link SeasonalItemGroup} will appear.
|
||||
*
|
||||
* @return the {@link Month} in which this {@link SeasonalCategory} appears
|
||||
* @return the {@link Month} in which this {@link SeasonalItemGroup} appears
|
||||
*/
|
||||
@Nonnull
|
||||
public Month getMonth() {
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.categories;
|
||||
package io.github.thebusybiscuit.slimefun4.api.items.groups;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
@ -9,34 +9,34 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
|
||||
/**
|
||||
* The {@link SubCategory} is a child {@link Category} of the
|
||||
* {@link MultiCategory}.
|
||||
* The {@link SubItemGroup} is a child {@link ItemGroup} of the
|
||||
* {@link NestedItemGroup}.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see MultiCategory
|
||||
* @see NestedItemGroup
|
||||
*
|
||||
*/
|
||||
public class SubCategory extends Category {
|
||||
public class SubItemGroup extends ItemGroup {
|
||||
|
||||
private final MultiCategory multiCategory;
|
||||
private final NestedItemGroup multiCategory;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public SubCategory(NamespacedKey key, MultiCategory parent, ItemStack item) {
|
||||
public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item) {
|
||||
this(key, parent, item, 3);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public SubCategory(NamespacedKey key, MultiCategory parent, ItemStack item, int tier) {
|
||||
public SubItemGroup(NamespacedKey key, NestedItemGroup parent, ItemStack item, int tier) {
|
||||
super(key, item, tier);
|
||||
|
||||
Validate.notNull(parent, "The parent category cannot be null");
|
||||
|
||||
multiCategory = parent;
|
||||
parent.addSubCategory(this);
|
||||
parent.addSubGroup(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -49,7 +49,7 @@ public class SubCategory extends Category {
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public final MultiCategory getParent() {
|
||||
public final NestedItemGroup getParent() {
|
||||
return multiCategory;
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This package contains a few {@link io.github.thebusybiscuit.slimefun4.api.items.ItemGroup} variations.
|
||||
*/
|
||||
package io.github.thebusybiscuit.slimefun4.api.items.groups;
|
@ -6,7 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to define an {@link Double} range
|
||||
|
@ -7,7 +7,7 @@ import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to allow {@link Enum} constants to be
|
||||
|
@ -6,7 +6,7 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to define an {@link Integer} range
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This variation of {@link ItemSetting} allows you to define a default {@link Tag}.
|
||||
|
@ -15,9 +15,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.World;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition;
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.github.thebusybiscuit.slimefun4.core.networks.NetworkManager;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.NetworkListener;
|
||||
|
||||
/**
|
||||
@ -248,7 +248,7 @@ public abstract class Network {
|
||||
public void display() {
|
||||
if (manager.isVisualizerEnabled()) {
|
||||
// TODO: Make Color configurable / network-dependent
|
||||
SlimefunPlugin.runSync(new NetworkVisualizer(this, Color.BLUE));
|
||||
Slimefun.runSync(new NetworkVisualizer(this, Color.BLUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,8 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.BackpackListener;
|
||||
|
||||
@ -125,7 +125,7 @@ public class PlayerBackpack {
|
||||
* The players who this Backpack will be shown to
|
||||
*/
|
||||
public void open(Player... players) {
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
for (Player p : players) {
|
||||
p.openInventory(inventory);
|
||||
}
|
||||
|
@ -30,19 +30,19 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.AsyncProfileLoadEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.gps.Waypoint;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.HashedArmorpiece;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectionType;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.ProtectiveArmor;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.GuideHistory;
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.armor.SlimefunArmorPiece;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
/**
|
||||
* A class that can store a Player's {@link Research} progress for caching purposes.
|
||||
@ -85,7 +85,7 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
private void loadProfileData() {
|
||||
for (Research research : SlimefunPlugin.getRegistry().getResearches()) {
|
||||
for (Research research : Slimefun.getRegistry().getResearches()) {
|
||||
if (configFile.contains("researches." + research.getID())) {
|
||||
researches.add(research);
|
||||
}
|
||||
@ -99,7 +99,7 @@ public class PlayerProfile {
|
||||
waypoints.add(new Waypoint(this, key, loc, waypointName));
|
||||
}
|
||||
} catch (Exception x) {
|
||||
SlimefunPlugin.logger().log(Level.WARNING, x, () -> "Could not load Waypoint \"" + key + "\" for Player \"" + name + '"');
|
||||
Slimefun.logger().log(Level.WARNING, x, () -> "Could not load Waypoint \"" + key + "\" for Player \"" + name + '"');
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -307,9 +307,9 @@ public class PlayerProfile {
|
||||
}
|
||||
|
||||
public @Nonnull String getTitle() {
|
||||
List<String> titles = SlimefunPlugin.getRegistry().getResearchRanks();
|
||||
List<String> titles = Slimefun.getRegistry().getResearchRanks();
|
||||
|
||||
float fraction = (float) researches.size() / SlimefunPlugin.getRegistry().getResearches().size();
|
||||
float fraction = (float) researches.size() / Slimefun.getRegistry().getResearches().size();
|
||||
int index = (int) (fraction * (titles.size() - 1));
|
||||
|
||||
return titles.get(index);
|
||||
@ -318,7 +318,7 @@ public class PlayerProfile {
|
||||
public void sendStats(@Nonnull CommandSender sender) {
|
||||
Set<Research> unlockedResearches = getResearches();
|
||||
int levels = unlockedResearches.stream().mapToInt(Research::getCost).sum();
|
||||
int allResearches = SlimefunPlugin.getRegistry().getResearches().size();
|
||||
int allResearches = Slimefun.getRegistry().getResearches().size();
|
||||
|
||||
float progress = Math.round(((unlockedResearches.size() * 100.0F) / allResearches) * 100.0F) / 100.0F;
|
||||
|
||||
@ -368,18 +368,18 @@ public class PlayerProfile {
|
||||
Validate.notNull(p, "Cannot get a PlayerProfile for: null!");
|
||||
|
||||
UUID uuid = p.getUniqueId();
|
||||
PlayerProfile profile = SlimefunPlugin.getRegistry().getPlayerProfiles().get(uuid);
|
||||
PlayerProfile profile = Slimefun.getRegistry().getPlayerProfiles().get(uuid);
|
||||
|
||||
if (profile != null) {
|
||||
callback.accept(profile);
|
||||
return true;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance(), () -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Slimefun.instance(), () -> {
|
||||
AsyncProfileLoadEvent event = new AsyncProfileLoadEvent(new PlayerProfile(p));
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
SlimefunPlugin.getRegistry().getPlayerProfiles().put(uuid, event.getProfile());
|
||||
Slimefun.getRegistry().getPlayerProfiles().put(uuid, event.getProfile());
|
||||
callback.accept(event.getProfile());
|
||||
});
|
||||
|
||||
@ -398,11 +398,11 @@ public class PlayerProfile {
|
||||
public static boolean request(@Nonnull OfflinePlayer p) {
|
||||
Validate.notNull(p, "Cannot request a Profile for null");
|
||||
|
||||
if (!SlimefunPlugin.getRegistry().getPlayerProfiles().containsKey(p.getUniqueId())) {
|
||||
if (!Slimefun.getRegistry().getPlayerProfiles().containsKey(p.getUniqueId())) {
|
||||
// Should probably prevent multiple requests for the same profile in the future
|
||||
Bukkit.getScheduler().runTaskAsynchronously(SlimefunPlugin.instance(), () -> {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Slimefun.instance(), () -> {
|
||||
PlayerProfile pp = new PlayerProfile(p);
|
||||
SlimefunPlugin.getRegistry().getPlayerProfiles().put(p.getUniqueId(), pp);
|
||||
Slimefun.getRegistry().getPlayerProfiles().put(p.getUniqueId(), pp);
|
||||
});
|
||||
|
||||
return false;
|
||||
@ -422,11 +422,11 @@ public class PlayerProfile {
|
||||
* @return An {@link Optional} describing the result
|
||||
*/
|
||||
public static @Nonnull Optional<PlayerProfile> find(@Nonnull OfflinePlayer p) {
|
||||
return Optional.ofNullable(SlimefunPlugin.getRegistry().getPlayerProfiles().get(p.getUniqueId()));
|
||||
return Optional.ofNullable(Slimefun.getRegistry().getPlayerProfiles().get(p.getUniqueId()));
|
||||
}
|
||||
|
||||
public static @Nonnull Iterator<PlayerProfile> iterator() {
|
||||
return SlimefunPlugin.getRegistry().getPlayerProfiles().values().iterator();
|
||||
return Slimefun.getRegistry().getPlayerProfiles().values().iterator();
|
||||
}
|
||||
|
||||
public static void getBackpack(@Nullable ItemStack item, @Nonnull Consumer<PlayerBackpack> callback) {
|
||||
@ -439,9 +439,9 @@ public class PlayerProfile {
|
||||
|
||||
for (String line : item.getItemMeta().getLore()) {
|
||||
if (line.startsWith(ChatColors.color("&7ID: ")) && line.indexOf('#') != -1) {
|
||||
String[] splitLine = PatternUtils.HASH.split(line);
|
||||
String[] splitLine = CommonPatterns.HASH.split(line);
|
||||
|
||||
if (PatternUtils.NUMERIC.matcher(splitLine[1]).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(splitLine[1]).matches()) {
|
||||
id = OptionalInt.of(Integer.parseInt(splitLine[1]));
|
||||
uuid = splitLine[0].replace(ChatColors.color("&7ID: "), "");
|
||||
}
|
||||
|
@ -6,12 +6,12 @@ import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
|
||||
|
||||
/**
|
||||
* A very simple API that is meant for adding/getting/clearing custom status effects
|
||||
@ -97,7 +97,7 @@ public class StatusEffect implements Keyed {
|
||||
Optional<String> optional = PersistentDataAPI.getOptionalString(p, getKey());
|
||||
|
||||
if (optional.isPresent()) {
|
||||
String[] data = PatternUtils.SEMICOLON.split(optional.get());
|
||||
String[] data = CommonPatterns.SEMICOLON.split(optional.get());
|
||||
long timestamp = Long.parseLong(data[1]);
|
||||
|
||||
if (timestamp == 0 || timestamp >= System.currentTimeMillis()) {
|
||||
@ -123,7 +123,7 @@ public class StatusEffect implements Keyed {
|
||||
Optional<String> optional = PersistentDataAPI.getOptionalString(p, getKey());
|
||||
|
||||
if (optional.isPresent()) {
|
||||
String[] data = PatternUtils.SEMICOLON.split(optional.get());
|
||||
String[] data = CommonPatterns.SEMICOLON.split(optional.get());
|
||||
return OptionalInt.of(Integer.parseInt(data[0]));
|
||||
} else {
|
||||
return OptionalInt.empty();
|
||||
|
@ -1,4 +1,4 @@
|
||||
package me.mrCookieSlime.Slimefun.Lists;
|
||||
package io.github.thebusybiscuit.slimefun4.api.recipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@ -21,50 +21,50 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.bakedlibs.dough.recipes.MinecraftRecipe;
|
||||
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AltarRecipe;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
// This class will be reworked and relocated in the "Recipe Rewrite"
|
||||
// TODO: Remove this class and rewrite the recipe system
|
||||
public class RecipeType implements Keyed {
|
||||
|
||||
public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "multiblock"), new CustomItem(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World"));
|
||||
public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge");
|
||||
public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone");
|
||||
public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery");
|
||||
public static final RecipeType ORE_CRUSHER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "ore_crusher"), SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher");
|
||||
public static final RecipeType GOLD_PAN = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "gold_pan"), SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item");
|
||||
public static final RecipeType COMPRESSOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "compressor"), SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor");
|
||||
public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "pressure_chamber"), SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber");
|
||||
public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "magic_workbench"), SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench");
|
||||
public static final RecipeType ORE_WASHER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "ore_washer"), SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer");
|
||||
public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power...");
|
||||
public static final RecipeType JUICER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation");
|
||||
public static final RecipeType MULTIBLOCK = new RecipeType(new NamespacedKey(Slimefun.instance(), "multiblock"), new CustomItemStack(Material.BRICKS, "&bMultiBlock", "", "&a&oBuild it in the World"));
|
||||
public static final RecipeType ARMOR_FORGE = new RecipeType(new NamespacedKey(Slimefun.instance(), "armor_forge"), SlimefunItems.ARMOR_FORGE, "", "&a&oCraft it in an Armor Forge");
|
||||
public static final RecipeType GRIND_STONE = new RecipeType(new NamespacedKey(Slimefun.instance(), "grind_stone"), SlimefunItems.GRIND_STONE, "", "&a&oGrind it using the Grind Stone");
|
||||
public static final RecipeType SMELTERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "smeltery"), SlimefunItems.SMELTERY, "", "&a&oSmelt it using a Smeltery");
|
||||
public static final RecipeType ORE_CRUSHER = new RecipeType(new NamespacedKey(Slimefun.instance(), "ore_crusher"), SlimefunItems.ORE_CRUSHER, "", "&a&oCrush it using the Ore Crusher");
|
||||
public static final RecipeType GOLD_PAN = new RecipeType(new NamespacedKey(Slimefun.instance(), "gold_pan"), SlimefunItems.GOLD_PAN, "", "&a&oUse a Gold Pan on Gravel to obtain this Item");
|
||||
public static final RecipeType COMPRESSOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "compressor"), SlimefunItems.COMPRESSOR, "", "&a&oCompress it using the Compressor");
|
||||
public static final RecipeType PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "pressure_chamber"), SlimefunItems.PRESSURE_CHAMBER, "", "&a&oCompress it using the Pressure Chamber");
|
||||
public static final RecipeType MAGIC_WORKBENCH = new RecipeType(new NamespacedKey(Slimefun.instance(), "magic_workbench"), SlimefunItems.MAGIC_WORKBENCH, "", "&a&oCraft it in a Magic Workbench");
|
||||
public static final RecipeType ORE_WASHER = new RecipeType(new NamespacedKey(Slimefun.instance(), "ore_washer"), SlimefunItems.ORE_WASHER, "", "&a&oWash it in an Ore Washer");
|
||||
public static final RecipeType ENHANCED_CRAFTING_TABLE = new RecipeType(new NamespacedKey(Slimefun.instance(), "enhanced_crafting_table"), SlimefunItems.ENHANCED_CRAFTING_TABLE, "", "&a&oA regular Crafting Table cannot", "&a&ohold this massive Amount of Power...");
|
||||
public static final RecipeType JUICER = new RecipeType(new NamespacedKey(Slimefun.instance(), "juicer"), SlimefunItems.JUICER, "", "&a&oUsed for Juice Creation");
|
||||
|
||||
public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR, (recipe, output) -> {
|
||||
public static final RecipeType ANCIENT_ALTAR = new RecipeType(new NamespacedKey(Slimefun.instance(), "ancient_altar"), SlimefunItems.ANCIENT_ALTAR, (recipe, output) -> {
|
||||
AltarRecipe altarRecipe = new AltarRecipe(Arrays.asList(recipe), output);
|
||||
AncientAltar altar = ((AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem());
|
||||
altar.getRecipes().add(altarRecipe);
|
||||
});
|
||||
|
||||
public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "mob_drop"), new CustomItem(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item");
|
||||
public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "barter_drop"), new CustomItem(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item");
|
||||
public static final RecipeType MOB_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "mob_drop"), new CustomItemStack(Material.IRON_SWORD, "&bMob Drop"), RecipeType::registerMobDrop, "", "&rKill the specified Mob to obtain this Item");
|
||||
public static final RecipeType BARTER_DROP = new RecipeType(new NamespacedKey(Slimefun.instance(), "barter_drop"), new CustomItemStack(Material.GOLD_INGOT, "&bBarter Drop"), RecipeType::registerBarterDrop, "&aBarter with piglins for a chance", "&ato obtain this item");
|
||||
|
||||
public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER);
|
||||
public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR);
|
||||
public static final RecipeType FOOD_COMPOSTER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER);
|
||||
public static final RecipeType FREEZER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "freezer"), SlimefunItems.FREEZER);
|
||||
public static final RecipeType REFINERY = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "refinery"), SlimefunItems.REFINERY);
|
||||
public static final RecipeType HEATED_PRESSURE_CHAMBER = new RecipeType(new NamespacedKey(Slimefun.instance(), "heated_pressure_chamber"), SlimefunItems.HEATED_PRESSURE_CHAMBER);
|
||||
public static final RecipeType FOOD_FABRICATOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_fabricator"), SlimefunItems.FOOD_FABRICATOR);
|
||||
public static final RecipeType FOOD_COMPOSTER = new RecipeType(new NamespacedKey(Slimefun.instance(), "food_composter"), SlimefunItems.FOOD_COMPOSTER);
|
||||
public static final RecipeType FREEZER = new RecipeType(new NamespacedKey(Slimefun.instance(), "freezer"), SlimefunItems.FREEZER);
|
||||
public static final RecipeType REFINERY = new RecipeType(new NamespacedKey(Slimefun.instance(), "refinery"), SlimefunItems.REFINERY);
|
||||
|
||||
public static final RecipeType GEO_MINER = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "geo_miner"), SlimefunItems.GEO_MINER);
|
||||
public static final RecipeType NUCLEAR_REACTOR = new RecipeType(new NamespacedKey(SlimefunPlugin.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR);
|
||||
public static final RecipeType GEO_MINER = new RecipeType(new NamespacedKey(Slimefun.instance(), "geo_miner"), SlimefunItems.GEO_MINER);
|
||||
public static final RecipeType NUCLEAR_REACTOR = new RecipeType(new NamespacedKey(Slimefun.instance(), "nuclear_reactor"), SlimefunItems.NUCLEAR_REACTOR);
|
||||
|
||||
public static final RecipeType NULL = new RecipeType();
|
||||
|
||||
@ -76,7 +76,7 @@ public class RecipeType implements Keyed {
|
||||
private RecipeType() {
|
||||
this.item = null;
|
||||
this.machine = "";
|
||||
this.key = new NamespacedKey(SlimefunPlugin.instance(), "null");
|
||||
this.key = new NamespacedKey(Slimefun.instance(), "null");
|
||||
}
|
||||
|
||||
public RecipeType(ItemStack item, String machine) {
|
||||
@ -84,9 +84,9 @@ public class RecipeType implements Keyed {
|
||||
this.machine = machine;
|
||||
|
||||
if (machine.length() > 0) {
|
||||
this.key = new NamespacedKey(SlimefunPlugin.instance(), machine.toLowerCase(Locale.ROOT));
|
||||
this.key = new NamespacedKey(Slimefun.instance(), machine.toLowerCase(Locale.ROOT));
|
||||
} else {
|
||||
this.key = new NamespacedKey(SlimefunPlugin.instance(), "unknown");
|
||||
this.key = new NamespacedKey(Slimefun.instance(), "unknown");
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,7 +95,7 @@ public class RecipeType implements Keyed {
|
||||
}
|
||||
|
||||
public RecipeType(NamespacedKey key, ItemStack item, BiConsumer<ItemStack[], ItemStack> callback, String... lore) {
|
||||
this.item = new CustomItem(item, null, lore);
|
||||
this.item = new CustomItemStack(item, null, lore);
|
||||
this.key = key;
|
||||
this.consumer = callback;
|
||||
|
||||
@ -122,7 +122,7 @@ public class RecipeType implements Keyed {
|
||||
if (consumer != null) {
|
||||
consumer.accept(recipe, result);
|
||||
} else {
|
||||
SlimefunItem slimefunItem = SlimefunItem.getByID(this.machine);
|
||||
SlimefunItem slimefunItem = SlimefunItem.getById(this.machine);
|
||||
|
||||
if (slimefunItem instanceof MultiBlockMachine) {
|
||||
((MultiBlockMachine) slimefunItem).addRecipe(recipe, result);
|
||||
@ -135,11 +135,11 @@ public class RecipeType implements Keyed {
|
||||
}
|
||||
|
||||
public @Nonnull ItemStack getItem(Player p) {
|
||||
return SlimefunPlugin.getLocalization().getRecipeTypeItem(p, this);
|
||||
return Slimefun.getLocalization().getRecipeTypeItem(p, this);
|
||||
}
|
||||
|
||||
public SlimefunItem getMachine() {
|
||||
return SlimefunItem.getByID(machine);
|
||||
return SlimefunItem.getById(machine);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -163,8 +163,8 @@ public class RecipeType implements Keyed {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private static void registerBarterDrop(ItemStack[] recipe, ItemStack output) {
|
||||
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||
SlimefunPlugin.getRegistry().getBarteringDrops().add(output);
|
||||
if (Slimefun.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
|
||||
Slimefun.getRegistry().getBarteringDrops().add(output);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,9 +172,9 @@ public class RecipeType implements Keyed {
|
||||
private static void registerMobDrop(ItemStack[] recipe, ItemStack output) {
|
||||
String mob = ChatColor.stripColor(recipe[4].getItemMeta().getDisplayName()).toUpperCase(Locale.ROOT).replace(' ', '_');
|
||||
EntityType entity = EntityType.valueOf(mob);
|
||||
Set<ItemStack> dropping = SlimefunPlugin.getRegistry().getMobDrops().getOrDefault(entity, new HashSet<>());
|
||||
Set<ItemStack> dropping = Slimefun.getRegistry().getMobDrops().getOrDefault(entity, new HashSet<>());
|
||||
dropping.add(output);
|
||||
SlimefunPlugin.getRegistry().getMobDrops().put(entity, dropping);
|
||||
Slimefun.getRegistry().getMobDrops().put(entity, dropping);
|
||||
}
|
||||
|
||||
public static List<ItemStack> getRecipeInputs(MultiBlockMachine machine) {
|
@ -0,0 +1,4 @@
|
||||
/**
|
||||
* This package contains all classes related to our recipe system.
|
||||
*/
|
||||
package io.github.thebusybiscuit.slimefun4.api.recipes;
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.researching;
|
||||
package io.github.thebusybiscuit.slimefun4.api.researches;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.FireworkUtils;
|
||||
|
||||
/**
|
||||
@ -63,9 +63,9 @@ public class PlayerResearchTask implements Consumer<PlayerProfile> {
|
||||
}
|
||||
|
||||
if (!isInstant) {
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1F);
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", "0%"));
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", "0%"));
|
||||
}, 5L);
|
||||
}
|
||||
|
||||
@ -74,14 +74,14 @@ public class PlayerResearchTask implements Consumer<PlayerProfile> {
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (isInstant) {
|
||||
SlimefunPlugin.runSync(() -> unlockResearch(p, profile));
|
||||
} else if (SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
|
||||
Slimefun.runSync(() -> unlockResearch(p, profile));
|
||||
} else if (Slimefun.getRegistry().getCurrentlyResearchingPlayers().add(p.getUniqueId())) {
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.research.start", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
|
||||
sendUpdateMessage(p);
|
||||
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
unlockResearch(p, profile);
|
||||
SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().remove(p.getUniqueId());
|
||||
Slimefun.getRegistry().getCurrentlyResearchingPlayers().remove(p.getUniqueId());
|
||||
}, (RESEARCH_PROGRESS.length + 1) * 20L);
|
||||
}
|
||||
}
|
||||
@ -92,10 +92,10 @@ public class PlayerResearchTask implements Consumer<PlayerProfile> {
|
||||
for (int i = 1; i < RESEARCH_PROGRESS.length + 1; i++) {
|
||||
int index = i;
|
||||
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 0.7F, 1);
|
||||
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> {
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.research.progress", true, msg -> {
|
||||
String progress = RESEARCH_PROGRESS[index - 1] + "%";
|
||||
return msg.replace(PLACEHOLDER, research.getName(p)).replace("%progress%", progress);
|
||||
});
|
||||
@ -105,11 +105,11 @@ public class PlayerResearchTask implements Consumer<PlayerProfile> {
|
||||
|
||||
private void unlockResearch(@Nonnull Player p, @Nonnull PlayerProfile profile) {
|
||||
profile.setResearched(research, true);
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.unlocked", true, msg -> msg.replace(PLACEHOLDER, research.getName(p)));
|
||||
onFinish(p);
|
||||
|
||||
// Check if the Server and the Player have enabled fireworks for researches
|
||||
if (SlimefunPlugin.getRegistry().isResearchFireworkEnabled() && SlimefunGuideSettings.hasFireworksEnabled(p)) {
|
||||
if (Slimefun.getRegistry().isResearchFireworkEnabled() && SlimefunGuideSettings.hasFireworksEnabled(p)) {
|
||||
FireworkUtils.launchRandom(p, 1);
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.researching;
|
||||
package io.github.thebusybiscuit.slimefun4.api.researches;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
@ -20,13 +20,13 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerPreResearchEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.ResearchUnlockEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* Represents a research, which is bound to one
|
||||
@ -88,7 +88,7 @@ public class Research implements Keyed {
|
||||
* @return Whether this {@link Research} is enabled or not
|
||||
*/
|
||||
public boolean isEnabled() {
|
||||
return SlimefunPlugin.getRegistry().isResearchingEnabled() && enabled;
|
||||
return Slimefun.getRegistry().isResearchingEnabled() && enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public class Research implements Keyed {
|
||||
*/
|
||||
@Nonnull
|
||||
public String getName(@Nonnull Player p) {
|
||||
String localized = SlimefunPlugin.getLocalization().getResearchName(p, key);
|
||||
String localized = Slimefun.getLocalization().getResearchName(p, key);
|
||||
return localized != null ? localized : name;
|
||||
}
|
||||
|
||||
@ -201,25 +201,25 @@ public class Research implements Keyed {
|
||||
* @param sfItem
|
||||
* The {@link SlimefunItem} on which the {@link Player} clicked.
|
||||
* @param category
|
||||
* The {@link Category} where the {@link Player} was.
|
||||
* The {@link ItemGroup} where the {@link Player} was.
|
||||
* @param page
|
||||
* The page number of where the {@link Player} was in the {@link Category};
|
||||
* The page number of where the {@link Player} was in the {@link ItemGroup};
|
||||
*
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, Category category, int page) {
|
||||
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(player.getUniqueId())) {
|
||||
public void unlockFromGuide(SlimefunGuideImplementation guide, Player player, PlayerProfile profile, SlimefunItem sfItem, ItemGroup category, int page) {
|
||||
if (!Slimefun.getRegistry().getCurrentlyResearchingPlayers().contains(player.getUniqueId())) {
|
||||
if (profile.hasUnlocked(this)) {
|
||||
guide.openCategory(profile, category, page);
|
||||
guide.openItemGroup(profile, category, page);
|
||||
} else {
|
||||
PlayerPreResearchEvent event = new PlayerPreResearchEvent(player, this, sfItem);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
if (this.canUnlock(player)) {
|
||||
guide.unlockItem(player, sfItem, pl -> guide.openCategory(profile, category, page));
|
||||
guide.unlockItem(player, sfItem, pl -> guide.openItemGroup(profile, category, page));
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(player, "messages.not-enough-xp", true);
|
||||
Slimefun.getLocalization().sendMessage(player, "messages.not-enough-xp", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -239,7 +239,7 @@ public class Research implements Keyed {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean creativeResearch = p.getGameMode() == GameMode.CREATIVE && SlimefunPlugin.getRegistry().isFreeCreativeResearchingEnabled();
|
||||
boolean creativeResearch = p.getGameMode() == GameMode.CREATIVE && Slimefun.getRegistry().isFreeCreativeResearchingEnabled();
|
||||
return creativeResearch || p.getLevel() >= cost;
|
||||
}
|
||||
|
||||
@ -273,10 +273,10 @@ public class Research implements Keyed {
|
||||
* Registers this {@link Research}.
|
||||
*/
|
||||
public void register() {
|
||||
SlimefunPlugin.getResearchCfg().setDefaultValue("enable-researching", true);
|
||||
Slimefun.getResearchCfg().setDefaultValue("enable-researching", true);
|
||||
String path = key.getNamespace() + '.' + key.getKey();
|
||||
|
||||
if (SlimefunPlugin.getResearchCfg().contains(path + ".enabled") && !SlimefunPlugin.getResearchCfg().getBoolean(path + ".enabled")) {
|
||||
if (Slimefun.getResearchCfg().contains(path + ".enabled") && !Slimefun.getResearchCfg().getBoolean(path + ".enabled")) {
|
||||
for (SlimefunItem item : new ArrayList<>(items)) {
|
||||
if (item != null) {
|
||||
item.setResearch(null);
|
||||
@ -287,13 +287,13 @@ public class Research implements Keyed {
|
||||
return;
|
||||
}
|
||||
|
||||
SlimefunPlugin.getResearchCfg().setDefaultValue(path + ".cost", getCost());
|
||||
SlimefunPlugin.getResearchCfg().setDefaultValue(path + ".enabled", true);
|
||||
Slimefun.getResearchCfg().setDefaultValue(path + ".cost", getCost());
|
||||
Slimefun.getResearchCfg().setDefaultValue(path + ".enabled", true);
|
||||
|
||||
setCost(SlimefunPlugin.getResearchCfg().getInt(path + ".cost"));
|
||||
setCost(Slimefun.getResearchCfg().getInt(path + ".cost"));
|
||||
enabled = true;
|
||||
|
||||
SlimefunPlugin.getRegistry().getResearches().add(this);
|
||||
Slimefun.getRegistry().getResearches().add(this);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,7 +310,7 @@ public class Research implements Keyed {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
for (Research research : SlimefunPlugin.getRegistry().getResearches()) {
|
||||
for (Research research : Slimefun.getRegistry().getResearches()) {
|
||||
if (research.getKey().equals(key)) {
|
||||
return Optional.of(research);
|
||||
}
|
@ -23,21 +23,22 @@ import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.collections.KeyMap;
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import io.github.bakedlibs.dough.collections.KeyMap;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlock;
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.api.BlockInfoConfig;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
|
||||
@ -56,7 +57,7 @@ public final class SlimefunRegistry {
|
||||
private final List<SlimefunItem> slimefunItems = new ArrayList<>();
|
||||
private final List<SlimefunItem> enabledItems = new ArrayList<>();
|
||||
|
||||
private final List<Category> categories = new ArrayList<>();
|
||||
private final List<ItemGroup> categories = new ArrayList<>();
|
||||
private final List<MultiBlock> multiblocks = new LinkedList<>();
|
||||
|
||||
private final List<Research> researches = new LinkedList<>();
|
||||
@ -93,7 +94,7 @@ public final class SlimefunRegistry {
|
||||
private final Map<String, UniversalBlockMenu> universalInventories = new HashMap<>();
|
||||
private final Map<Class<? extends ItemHandler>, Set<ItemHandler>> globalItemHandlers = new HashMap<>();
|
||||
|
||||
public void load(@Nonnull SlimefunPlugin plugin, @Nonnull Config cfg) {
|
||||
public void load(@Nonnull Slimefun plugin, @Nonnull Config cfg) {
|
||||
Validate.notNull(plugin, "The Plugin cannot be null!");
|
||||
Validate.notNull(cfg, "The Config cannot be null!");
|
||||
|
||||
@ -164,12 +165,11 @@ public final class SlimefunRegistry {
|
||||
}
|
||||
|
||||
/**
|
||||
* This returns a {@link List} containing every enabled {@link Category}.
|
||||
* This returns a {@link List} containing every enabled {@link ItemGroup}.
|
||||
*
|
||||
* @return {@link List} containing every enabled {@link Category}
|
||||
* @return {@link List} containing every enabled {@link ItemGroup}
|
||||
*/
|
||||
@Nonnull
|
||||
public List<Category> getCategories() {
|
||||
public @Nonnull List<ItemGroup> getAllItemGroups() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
@ -178,8 +178,7 @@ public final class SlimefunRegistry {
|
||||
*
|
||||
* @return A {@link List} containing every {@link SlimefunItem}
|
||||
*/
|
||||
@Nonnull
|
||||
public List<SlimefunItem> getAllSlimefunItems() {
|
||||
public @Nonnull List<SlimefunItem> getAllSlimefunItems() {
|
||||
return slimefunItems;
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -11,8 +10,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.Damageable;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.bakedlibs.dough.config.Config;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.UnbreakingAlgorithm;
|
||||
|
||||
/**
|
||||
* This interface, when attached to a {@link SlimefunItem}, provides an easy method for damaging
|
||||
|
@ -7,15 +7,16 @@ import javax.annotation.Nonnull;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition;
|
||||
import io.github.bakedlibs.dough.blocks.BlockPosition;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
|
||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.BlockStorage;
|
||||
|
||||
/**
|
||||
@ -140,7 +141,7 @@ public interface EnergyNetComponent extends ItemAttribute {
|
||||
}
|
||||
}
|
||||
} catch (Exception | LinkageError x) {
|
||||
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "Exception while trying to set the energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
|
||||
Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to set the energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,7 +168,7 @@ public interface EnergyNetComponent extends ItemAttribute {
|
||||
}
|
||||
}
|
||||
} catch (Exception | LinkageError x) {
|
||||
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "Exception while trying to add an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
|
||||
Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to add an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
|
||||
}
|
||||
}
|
||||
|
||||
@ -194,7 +195,7 @@ public interface EnergyNetComponent extends ItemAttribute {
|
||||
}
|
||||
}
|
||||
} catch (Exception | LinkageError x) {
|
||||
SlimefunPlugin.logger().log(Level.SEVERE, x, () -> "Exception while trying to remove an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
|
||||
Slimefun.logger().log(Level.SEVERE, x, () -> "Exception while trying to remove an energy-charge for \"" + getId() + "\" at " + new BlockPosition(l));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
|
||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.AbstractEnergyProvider;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
|
||||
|
@ -6,9 +6,9 @@ import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.holograms.HologramsService;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.HologramProjector;
|
||||
|
||||
/**
|
||||
@ -33,7 +33,7 @@ public interface HologramOwner extends ItemAttribute {
|
||||
*/
|
||||
default void updateHologram(@Nonnull Block b, @Nonnull String text) {
|
||||
Location loc = b.getLocation().add(getHologramOffset(b));
|
||||
SlimefunPlugin.getHologramsService().setHologramLabel(loc, ChatColors.color(text));
|
||||
Slimefun.getHologramsService().setHologramLabel(loc, ChatColors.color(text));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,7 +44,7 @@ public interface HologramOwner extends ItemAttribute {
|
||||
*/
|
||||
default void removeHologram(@Nonnull Block b) {
|
||||
Location loc = b.getLocation().add(getHologramOffset(b));
|
||||
SlimefunPlugin.getHologramsService().removeHologram(loc);
|
||||
Slimefun.getHologramsService().removeHologram(loc);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,7 +59,7 @@ public interface HologramOwner extends ItemAttribute {
|
||||
*/
|
||||
@Nonnull
|
||||
default Vector getHologramOffset(@Nonnull Block block) {
|
||||
return SlimefunPlugin.getHologramsService().getDefaultOffset();
|
||||
return Slimefun.getHologramsService().getDefaultOffset();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2,8 +2,8 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* An empty interface that only serves the purpose of bundling together all
|
||||
|
@ -2,9 +2,9 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.machines.MachineOperation;
|
||||
import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This {@link ItemAttribute} marks a {@link SlimefunItem} as a {@link MachineProcessHolder}.
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* Implement this interface for any {@link SlimefunItem} to prevent
|
||||
|
@ -3,7 +3,7 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* Implement this interface for any {@link SlimefunItem} to prevent
|
||||
|
@ -3,9 +3,9 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.event.entity.EntityDropItemEvent;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.PiglinListener;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This interface, when attached to a {@link SlimefunItem}, provides a variable (0-100%) chance for
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* <strong>DO NOT IMPLEMENT THIS INTERFACE</strong>
|
||||
|
@ -2,7 +2,7 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks
|
||||
|
@ -4,10 +4,10 @@ import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuitBoard;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.entity.MobDropListener;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This interface, when attached to a {@link SlimefunItem}, provides an easy method for adding
|
||||
|
@ -1,16 +1,16 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChargeUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.MultiTool;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.machines.ChargingBench;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChargeUtils;
|
||||
|
||||
/**
|
||||
* A {@link Rechargeable} {@link SlimefunItem} can hold energy and is able to
|
||||
|
@ -7,11 +7,12 @@ import javax.annotation.Nonnull;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.tools.GoldPan;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
|
||||
|
||||
/**
|
||||
@ -49,6 +50,6 @@ public interface RecipeDisplayItem extends ItemAttribute {
|
||||
|
||||
@Nonnull
|
||||
default String getRecipeSectionLabel(@Nonnull Player p) {
|
||||
return "&7\u21E9 " + SlimefunPlugin.getLocalization().getMessage(p, getLabelLocalPath()) + " \u21E9";
|
||||
return "&7\u21E9 " + Slimefun.getLocalization().getMessage(p, getLabelLocalPath()) + " \u21E9";
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.attributes;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.SoulboundItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks
|
||||
|
@ -5,8 +5,8 @@ import javax.annotation.Nonnull;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Wither;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.WitherProofBlock;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This Interface, when attached to a class that inherits from {@link SlimefunItem}, marks
|
||||
|
@ -1,6 +0,0 @@
|
||||
/**
|
||||
* This package stores API classes that are centered around the extension of the
|
||||
* {@link me.mrCookieSlime.Slimefun.Objects.Category} class, such as
|
||||
* {@link io.github.thebusybiscuit.slimefun4.core.categories.SeasonalCategory} for example.
|
||||
*/
|
||||
package io.github.thebusybiscuit.slimefun4.core.categories;
|
@ -16,9 +16,9 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.subcommands.SlimefunSubCommands;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* This {@link CommandExecutor} holds the functionality of our {@code /slimefun} command.
|
||||
@ -29,7 +29,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
|
||||
private boolean registered = false;
|
||||
private final SlimefunPlugin plugin;
|
||||
private final Slimefun plugin;
|
||||
private final List<SubCommand> commands = new LinkedList<>();
|
||||
private final Map<SubCommand, Integer> commandUsage = new HashMap<>();
|
||||
|
||||
@ -37,9 +37,9 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
* Creates a new instance of {@link SlimefunCommand}
|
||||
*
|
||||
* @param plugin
|
||||
* The instance of our {@link SlimefunPlugin}
|
||||
* The instance of our {@link Slimefun}
|
||||
*/
|
||||
public SlimefunCommand(@Nonnull SlimefunPlugin plugin) {
|
||||
public SlimefunCommand(@Nonnull Slimefun plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
commands.addAll(SlimefunSubCommands.getAllCommands(this));
|
||||
}
|
||||
|
||||
public @Nonnull SlimefunPlugin getPlugin() {
|
||||
public @Nonnull Slimefun getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class SlimefunCommand implements CommandExecutor, Listener {
|
||||
|
||||
public void sendHelp(@Nonnull CommandSender sender) {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + SlimefunPlugin.getVersion()));
|
||||
sender.sendMessage(ChatColors.color("&aSlimefun &2v" + Slimefun.getVersion()));
|
||||
sender.sendMessage("");
|
||||
|
||||
for (SubCommand cmd : commands) {
|
||||
|
@ -14,9 +14,9 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class SlimefunTabCompleter implements TabCompleter {
|
||||
|
||||
@ -37,7 +37,7 @@ class SlimefunTabCompleter implements TabCompleter {
|
||||
if (args[0].equalsIgnoreCase("give")) {
|
||||
return createReturnList(getSlimefunItems(), args[2]);
|
||||
} else if (args[0].equalsIgnoreCase("research")) {
|
||||
List<Research> researches = SlimefunPlugin.getRegistry().getResearches();
|
||||
List<Research> researches = Slimefun.getRegistry().getResearches();
|
||||
List<String> suggestions = new LinkedList<>();
|
||||
|
||||
suggestions.add("all");
|
||||
@ -95,7 +95,7 @@ class SlimefunTabCompleter implements TabCompleter {
|
||||
|
||||
@Nonnull
|
||||
private List<String> getSlimefunItems() {
|
||||
List<SlimefunItem> items = SlimefunPlugin.getRegistry().getEnabledSlimefunItems();
|
||||
List<SlimefunItem> items = Slimefun.getRegistry().getEnabledSlimefunItems();
|
||||
List<String> list = new ArrayList<>(items.size());
|
||||
|
||||
for (SlimefunItem item : items) {
|
||||
|
@ -11,7 +11,7 @@ import org.bukkit.command.defaults.HelpCommand;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* This class represents a {@link SubCommand}, it is a {@link Command} that starts with
|
||||
@ -24,14 +24,14 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
*/
|
||||
public abstract class SubCommand {
|
||||
|
||||
protected final SlimefunPlugin plugin;
|
||||
protected final Slimefun plugin;
|
||||
protected final SlimefunCommand cmd;
|
||||
|
||||
private final String name;
|
||||
private final boolean hidden;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
protected SubCommand(SlimefunPlugin plugin, SlimefunCommand cmd, String name, boolean hidden) {
|
||||
protected SubCommand(Slimefun plugin, SlimefunCommand cmd, String name, boolean hidden) {
|
||||
this.plugin = plugin;
|
||||
this.cmd = cmd;
|
||||
|
||||
@ -83,9 +83,9 @@ public abstract class SubCommand {
|
||||
@Nonnull
|
||||
public String getDescription(@Nonnull CommandSender sender) {
|
||||
if (sender instanceof Player) {
|
||||
return SlimefunPlugin.getLocalization().getMessage((Player) sender, getDescription());
|
||||
return Slimefun.getLocalization().getMessage((Player) sender, getDescription());
|
||||
} else {
|
||||
return SlimefunPlugin.getLocalization().getMessage(getDescription());
|
||||
return Slimefun.getLocalization().getMessage(getDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,13 +8,13 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.RestoredBackpack;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
|
||||
/**
|
||||
* This command that allows for backpack retrieval in the event they are lost.
|
||||
@ -29,7 +29,7 @@ import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
class BackpackCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
BackpackCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
BackpackCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "backpack", false);
|
||||
}
|
||||
|
||||
@ -43,12 +43,12 @@ class BackpackCommand extends SubCommand {
|
||||
if (sender instanceof Player) {
|
||||
if (sender.hasPermission("slimefun.command.backpack")) {
|
||||
if (args.length != 3) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack <Player> <ID>"));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf backpack <Player> <ID>"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PatternUtils.NUMERIC.matcher(args[2]).matches()) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.invalid-id");
|
||||
if (!CommonPatterns.NUMERIC.matcher(args[2]).matches()) {
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.backpack.invalid-id");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ class BackpackCommand extends SubCommand {
|
||||
OfflinePlayer backpackOwner = Bukkit.getOfflinePlayer(args[1]);
|
||||
|
||||
if (!(backpackOwner instanceof Player) && !backpackOwner.hasPlayedBefore()) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.player-never-joined");
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.backpack.player-never-joined");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -64,22 +64,22 @@ class BackpackCommand extends SubCommand {
|
||||
|
||||
PlayerProfile.get(backpackOwner, profile -> {
|
||||
if (!profile.getBackpack(id).isPresent()) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.backpack-does-not-exist");
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.backpack.backpack-does-not-exist");
|
||||
return;
|
||||
}
|
||||
|
||||
SlimefunPlugin.runSync(() -> {
|
||||
Slimefun.runSync(() -> {
|
||||
ItemStack item = SlimefunItems.RESTORED_BACKPACK.clone();
|
||||
SlimefunPlugin.getBackpackListener().setBackpackId(backpackOwner, item, 2, id);
|
||||
Slimefun.getBackpackListener().setBackpackId(backpackOwner, item, 2, id);
|
||||
((Player) sender).getInventory().addItem(item);
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given");
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.backpack.restored-backpack-given");
|
||||
});
|
||||
});
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,11 +6,11 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* {@link ChargeCommand} adds an in game command which charges any {@link Rechargeable}
|
||||
@ -22,7 +22,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
class ChargeCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
ChargeCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
ChargeCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "charge", false);
|
||||
}
|
||||
|
||||
@ -42,15 +42,15 @@ class ChargeCommand extends SubCommand {
|
||||
if (slimefunItem instanceof Rechargeable) {
|
||||
Rechargeable rechargeableItem = (Rechargeable) slimefunItem;
|
||||
rechargeableItem.setItemCharge(item, rechargeableItem.getMaxItemCharge(item));
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.charge-success", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.charge.charge-success", true);
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.charge.not-rechargeable", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,12 @@ import org.bukkit.entity.Player;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class CheatCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
CheatCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
CheatCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "cheat", false);
|
||||
}
|
||||
|
||||
@ -23,10 +23,10 @@ class CheatCommand extends SubCommand {
|
||||
if (sender.hasPermission("slimefun.cheat.items")) {
|
||||
SlimefunGuide.openCheatMenu((Player) sender);
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,12 +8,12 @@ import org.bukkit.entity.Player;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class DebugFishCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
DebugFishCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
DebugFishCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "debug_fish", true);
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ class DebugFishCommand extends SubCommand {
|
||||
if (sender instanceof Player && sender.hasPermission("slimefun.debugging")) {
|
||||
((Player) sender).getInventory().addItem(SlimefunItems.DEBUG_FISH.clone());
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,24 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.commands.subcommands;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.cscorelib2.players.PlayerList;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.common.PlayerList;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class GiveCommand extends SubCommand {
|
||||
|
||||
private static final String PLACEHOLDER_PLAYER = "%player%";
|
||||
@ -25,7 +26,7 @@ class GiveCommand extends SubCommand {
|
||||
private static final String PLACEHOLDER_AMOUNT = "%amount%";
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
GiveCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
GiveCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "give", false);
|
||||
}
|
||||
|
||||
@ -38,42 +39,42 @@ class GiveCommand extends SubCommand {
|
||||
if (player.isPresent()) {
|
||||
Player p = player.get();
|
||||
|
||||
SlimefunItem sfItem = SlimefunItem.getByID(args[2].toUpperCase(Locale.ROOT));
|
||||
SlimefunItem sfItem = SlimefunItem.getById(args[2].toUpperCase(Locale.ROOT));
|
||||
|
||||
if (sfItem != null) {
|
||||
giveItem(sender, p, sfItem, args);
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.invalid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2]));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.invalid-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, args[2]));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf give <Player> <Slimefun Item> [Amount]"));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf give <Player> <Slimefun Item> [Amount]"));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void giveItem(CommandSender sender, Player p, SlimefunItem sfItem, String[] args) {
|
||||
if (sfItem instanceof MultiBlockMachine) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "guide.cheat.no-multiblocks");
|
||||
Slimefun.getLocalization().sendMessage(sender, "guide.cheat.no-multiblocks");
|
||||
} 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<Integer, ItemStack> excess = p.getInventory().addItem(new CustomItem(sfItem.getItem(), amount));
|
||||
if (SlimefunPlugin.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) {
|
||||
Slimefun.getLocalization().sendMessage(p, "messages.given-item", true, msg -> msg.replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
|
||||
Map<Integer, ItemStack> excess = p.getInventory().addItem(new CustomItemStack(sfItem.getItem(), amount));
|
||||
if (Slimefun.getCfg().getBoolean("options.drop-excess-sf-give-items") && !excess.isEmpty()) {
|
||||
for (ItemStack is : excess.values()) {
|
||||
p.getWorld().dropItem(p.getLocation(), is);
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.give-item", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]).replace(PLACEHOLDER_ITEM, sfItem.getItemName()).replace(PLACEHOLDER_AMOUNT, String.valueOf(amount)));
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.invalid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3]));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.invalid-amount", true, msg -> msg.replace(PLACEHOLDER_AMOUNT, args[3]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -82,7 +83,7 @@ class GiveCommand extends SubCommand {
|
||||
int amount = 1;
|
||||
|
||||
if (args.length == 4) {
|
||||
if (PatternUtils.NUMERIC.matcher(args[3]).matches()) {
|
||||
if (CommonPatterns.NUMERIC.matcher(args[3]).matches()) {
|
||||
amount = Integer.parseInt(args[3]);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -9,12 +9,12 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class GuideCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
GuideCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
GuideCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "guide", false);
|
||||
}
|
||||
|
||||
@ -25,10 +25,10 @@ class GuideCommand extends SubCommand {
|
||||
SlimefunGuideMode design = SlimefunGuide.getDefaultMode();
|
||||
((Player) sender).getInventory().addItem(SlimefunGuide.getItem(design).clone());
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,12 +6,12 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class HelpCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
HelpCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
HelpCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "help", false);
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class OpenGuideCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
OpenGuideCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
OpenGuideCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "open_guide", false);
|
||||
}
|
||||
|
||||
@ -25,10 +25,10 @@ class OpenGuideCommand extends SubCommand {
|
||||
if (sender.hasPermission("slimefun.command.open_guide")) {
|
||||
SlimefunGuide.openGuide((Player) sender, SlimefunGuideMode.SURVIVAL_MODE);
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,12 +9,12 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.players.PlayerList;
|
||||
import io.github.bakedlibs.dough.common.PlayerList;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class ResearchCommand extends SubCommand {
|
||||
|
||||
@ -22,7 +22,7 @@ class ResearchCommand extends SubCommand {
|
||||
private static final String PLACEHOLDER_RESEARCH = "%research%";
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
ResearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
ResearchCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "research", false);
|
||||
}
|
||||
|
||||
@ -51,13 +51,13 @@ class ResearchCommand extends SubCommand {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace(PLACEHOLDER_PLAYER, args[1]));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf research <Player> <all/reset/Research>"));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf research <Player> <all/reset/Research>"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,18 +68,18 @@ class ResearchCommand extends SubCommand {
|
||||
if (research.isPresent()) {
|
||||
research.get().unlock(p, true, player -> {
|
||||
UnaryOperator<String> variables = msg -> msg.replace(PLACEHOLDER_PLAYER, player.getName()).replace(PLACEHOLDER_RESEARCH, research.get().getName(player));
|
||||
SlimefunPlugin.getLocalization().sendMessage(player, "messages.give-research", true, variables);
|
||||
Slimefun.getLocalization().sendMessage(player, "messages.give-research", true, variables);
|
||||
});
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.invalid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.invalid-research", true, msg -> msg.replace(PLACEHOLDER_RESEARCH, input));
|
||||
}
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private void researchAll(CommandSender sender, PlayerProfile profile, Player p) {
|
||||
for (Research res : SlimefunPlugin.getRegistry().getResearches()) {
|
||||
for (Research res : Slimefun.getRegistry().getResearches()) {
|
||||
if (!profile.hasUnlocked(res)) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()).replace(PLACEHOLDER_RESEARCH, res.getName(p)));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.give-research", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()).replace(PLACEHOLDER_RESEARCH, res.getName(p)));
|
||||
}
|
||||
|
||||
res.unlock(p, true);
|
||||
@ -88,11 +88,11 @@ class ResearchCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private void reset(PlayerProfile profile, Player p) {
|
||||
for (Research research : SlimefunPlugin.getRegistry().getResearches()) {
|
||||
for (Research research : Slimefun.getRegistry().getResearches()) {
|
||||
profile.setResearched(research, false);
|
||||
}
|
||||
|
||||
SlimefunPlugin.getLocalization().sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()));
|
||||
Slimefun.getLocalization().sendMessage(p, "commands.research.reset", true, msg -> msg.replace(PLACEHOLDER_PLAYER, p.getName()));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@ -101,7 +101,7 @@ class ResearchCommand extends SubCommand {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
for (Research research : SlimefunPlugin.getRegistry().getResearches()) {
|
||||
for (Research research : Slimefun.getRegistry().getResearches()) {
|
||||
if (research.getKey().toString().equalsIgnoreCase(input)) {
|
||||
return Optional.of(research);
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class SearchCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
SearchCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
SearchCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "search", false);
|
||||
}
|
||||
|
||||
@ -29,13 +29,13 @@ class SearchCommand extends SubCommand {
|
||||
String query = String.join(" ", Arrays.copyOfRange(args, 1, args.length));
|
||||
PlayerProfile.get((Player) sender, profile -> SlimefunGuide.openSearch(profile, query, SlimefunGuideMode.SURVIVAL_MODE, true));
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search <SearchTerm>"));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.usage", true, msg -> msg.replace("%usage%", "/sf search <SearchTerm>"));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ import javax.annotation.Nonnull;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* This class holds the implementations of every {@link SubCommand}.
|
||||
@ -24,7 +24,7 @@ public final class SlimefunSubCommands {
|
||||
|
||||
@Nonnull
|
||||
public static Collection<SubCommand> getAllCommands(@Nonnull SlimefunCommand cmd) {
|
||||
SlimefunPlugin plugin = cmd.getPlugin();
|
||||
Slimefun plugin = cmd.getPlugin();
|
||||
List<SubCommand> commands = new LinkedList<>();
|
||||
|
||||
commands.add(new HelpCommand(plugin, cmd));
|
||||
|
@ -8,16 +8,16 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.players.PlayerList;
|
||||
import io.github.bakedlibs.dough.common.PlayerList;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class StatsCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
StatsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
StatsCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "stats", false);
|
||||
}
|
||||
|
||||
@ -30,15 +30,15 @@ class StatsCommand extends SubCommand {
|
||||
if (player.isPresent()) {
|
||||
PlayerProfile.get(player.get(), profile -> profile.sendStats(sender));
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.not-online", true, msg -> msg.replace("%player%", args[1]));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
} else if (sender instanceof Player) {
|
||||
PlayerProfile.get((Player) sender, profile -> profile.sendStats(sender));
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players", true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,12 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class TeleporterCommand extends SubCommand {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
TeleporterCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
TeleporterCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "teleporter", false);
|
||||
}
|
||||
|
||||
@ -25,25 +25,25 @@ class TeleporterCommand extends SubCommand {
|
||||
if (sender.hasPermission("slimefun.command.teleporter")) {
|
||||
if (args.length == 1) {
|
||||
Player p = (Player) sender;
|
||||
SlimefunPlugin.getGPSNetwork().getTeleportationManager().openTeleporterGUI(p, p.getUniqueId(), p.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
|
||||
Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI(p, p.getUniqueId(), p.getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
|
||||
} 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);
|
||||
Slimefun.getGPSNetwork().getTeleportationManager().openTeleporterGUI((Player) sender, player.getUniqueId(), ((Player) sender).getLocation().getBlock().getRelative(BlockFace.DOWN), 999999999);
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1]));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.unknown-player", msg -> msg.replace("%player%", args[1]));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]"));
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.usage", msg -> msg.replace("%usage%", "/sf teleporter [Player]"));
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission");
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission");
|
||||
}
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.only-players");
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.only-players");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.profiler.PerformanceInspector;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.ConsolePerformanceInspector;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.profiler.inspectors.PlayerPerformanceInspector;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class TimingsCommand extends SubCommand {
|
||||
|
||||
@ -25,7 +25,7 @@ class TimingsCommand extends SubCommand {
|
||||
private final Set<String> flags = new HashSet<>(Arrays.asList("verbose"));
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
TimingsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
TimingsCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "timings", false);
|
||||
}
|
||||
|
||||
@ -44,16 +44,16 @@ class TimingsCommand extends SubCommand {
|
||||
boolean verbose = hasFlag(args, "verbose");
|
||||
|
||||
if (verbose && sender instanceof Player) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.timings.verbose-player", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.timings.verbose-player", true);
|
||||
return;
|
||||
}
|
||||
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.timings.please-wait", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.timings.please-wait", true);
|
||||
|
||||
PerformanceInspector inspector = inspectorOf(sender, verbose);
|
||||
SlimefunPlugin.getProfiler().requestSummary(inspector);
|
||||
Slimefun.getProfiler().requestSummary(inspector);
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,7 +67,7 @@ class TimingsCommand extends SubCommand {
|
||||
|
||||
if (argument.startsWith(FLAG_PREFIX) && !flags.contains(argument.substring(2))) {
|
||||
hasInvalidFlags = true;
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument));
|
||||
Slimefun.getLocalization().sendMessage(sender, "commands.timings.unknown-flag", true, msg -> msg.replace("%flag%", argument));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,9 +13,10 @@ import org.bukkit.plugin.Plugin;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SlimefunCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.core.commands.SubCommand;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.papermc.lib.PaperLib;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
@ -44,7 +45,7 @@ class VersionsCommand extends SubCommand {
|
||||
private static final String JAVA_VERSION_NOTICE = "As of Minecraft 1.17 Java 16 will be required!";
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
VersionsCommand(SlimefunPlugin plugin, SlimefunCommand cmd) {
|
||||
VersionsCommand(Slimefun plugin, SlimefunCommand cmd) {
|
||||
super(plugin, cmd, "versions", false);
|
||||
}
|
||||
|
||||
@ -67,22 +68,22 @@ class VersionsCommand extends SubCommand {
|
||||
.color(ChatColor.DARK_GREEN)
|
||||
.append("Slimefun ")
|
||||
.color(ChatColor.GREEN)
|
||||
.append(SlimefunPlugin.getVersion() + '\n')
|
||||
.append(Slimefun.getVersion() + '\n')
|
||||
.color(ChatColor.DARK_GREEN);
|
||||
// @formatter:on
|
||||
|
||||
if (SlimefunPlugin.getMetricsService().getVersion() != null) {
|
||||
if (Slimefun.getMetricsService().getVersion() != null) {
|
||||
// @formatter:off
|
||||
builder.append("Metrics-Module ")
|
||||
.color(ChatColor.GREEN)
|
||||
.append("#" + SlimefunPlugin.getMetricsService().getVersion() + '\n')
|
||||
.append("#" + Slimefun.getMetricsService().getVersion() + '\n')
|
||||
.color(ChatColor.DARK_GREEN);
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
addJavaVersion(builder);
|
||||
|
||||
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
|
||||
if (Slimefun.getRegistry().isBackwardsCompatible()) {
|
||||
// @formatter:off
|
||||
HoverEvent hoverEvent = new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text(
|
||||
"Backwards compatibility has a negative impact on performance!\n" +
|
||||
@ -99,7 +100,7 @@ class VersionsCommand extends SubCommand {
|
||||
|
||||
sender.spigot().sendMessage(builder.create());
|
||||
} else {
|
||||
SlimefunPlugin.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
Slimefun.getLocalization().sendMessage(sender, "messages.no-permission", true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +124,7 @@ class VersionsCommand extends SubCommand {
|
||||
}
|
||||
|
||||
private void addPluginVersions(@Nonnull ComponentBuilder builder) {
|
||||
Collection<Plugin> addons = SlimefunPlugin.getInstalledAddons();
|
||||
Collection<Plugin> addons = Slimefun.getInstalledAddons();
|
||||
|
||||
if (addons.isEmpty()) {
|
||||
builder.append("No Addons installed").color(ChatColor.GRAY).italic(true);
|
||||
|
@ -10,9 +10,9 @@ import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* {@link GuideHistory} represents the browsing history of a {@link Player} through the
|
||||
@ -70,16 +70,16 @@ public class GuideHistory {
|
||||
}
|
||||
|
||||
/**
|
||||
* This method adds a {@link Category} to this {@link GuideHistory}.
|
||||
* Should the {@link Category} already be the last element in this {@link GuideHistory},
|
||||
* This method adds a {@link ItemGroup} to this {@link GuideHistory}.
|
||||
* Should the {@link ItemGroup} already be the last element in this {@link GuideHistory},
|
||||
* then the entry will be overridden with the new page.
|
||||
*
|
||||
* @param category
|
||||
* The {@link Category} that should be added to this {@link GuideHistory}
|
||||
* The {@link ItemGroup} that should be added to this {@link GuideHistory}
|
||||
* @param page
|
||||
* The current page of the {@link Category} that should be stored
|
||||
* The current page of the {@link ItemGroup} that should be stored
|
||||
*/
|
||||
public void add(@Nonnull Category category, int page) {
|
||||
public void add(@Nonnull ItemGroup category, int page) {
|
||||
refresh(category, page);
|
||||
}
|
||||
|
||||
@ -188,8 +188,8 @@ public class GuideHistory {
|
||||
private <T> void open(@Nonnull SlimefunGuideImplementation guide, @Nullable GuideEntry<T> entry) {
|
||||
if (entry == null) {
|
||||
guide.openMainMenu(profile, mainMenuPage);
|
||||
} else if (entry.getIndexedObject() instanceof Category) {
|
||||
guide.openCategory(profile, (Category) entry.getIndexedObject(), entry.getPage());
|
||||
} else if (entry.getIndexedObject() instanceof ItemGroup) {
|
||||
guide.openItemGroup(profile, (ItemGroup) entry.getIndexedObject(), entry.getPage());
|
||||
} else if (entry.getIndexedObject() instanceof SlimefunItem) {
|
||||
guide.displayItem(profile, (SlimefunItem) entry.getIndexedObject(), false);
|
||||
} else if (entry.getIndexedObject() instanceof ItemStack) {
|
||||
|
@ -10,14 +10,13 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.itemstack.SlimefunGuideItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This is a static utility class that provides convenient access to the methods
|
||||
@ -35,7 +34,7 @@ public final class SlimefunGuide {
|
||||
|
||||
@Nonnull
|
||||
public static ItemStack getItem(@Nonnull SlimefunGuideMode design) {
|
||||
return SlimefunPlugin.getRegistry().getSlimefunGuide(design).getItem();
|
||||
return Slimefun.getRegistry().getSlimefunGuide(design).getItem();
|
||||
}
|
||||
|
||||
public static void openCheatMenu(@Nonnull Player p) {
|
||||
@ -55,7 +54,7 @@ public final class SlimefunGuide {
|
||||
}
|
||||
|
||||
public static void openGuide(@Nonnull Player p, @Nonnull SlimefunGuideMode mode) {
|
||||
if (!SlimefunPlugin.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
||||
if (!Slimefun.getWorldSettingsService().isWorldEnabled(p.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -63,7 +62,7 @@ public final class SlimefunGuide {
|
||||
|
||||
if (optional.isPresent()) {
|
||||
PlayerProfile profile = optional.get();
|
||||
SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getSlimefunGuide(mode);
|
||||
SlimefunGuideImplementation guide = Slimefun.getRegistry().getSlimefunGuide(mode);
|
||||
profile.getGuideHistory().openLastEntry(guide);
|
||||
} else {
|
||||
openMainMenuAsync(p, mode, 1);
|
||||
@ -72,35 +71,35 @@ public final class SlimefunGuide {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private static void openMainMenuAsync(Player player, SlimefunGuideMode mode, int selectedPage) {
|
||||
if (!PlayerProfile.get(player, profile -> SlimefunPlugin.runSync(() -> openMainMenu(profile, mode, selectedPage)))) {
|
||||
SlimefunPlugin.getLocalization().sendMessage(player, "messages.opening-guide");
|
||||
if (!PlayerProfile.get(player, profile -> Slimefun.runSync(() -> openMainMenu(profile, mode, selectedPage)))) {
|
||||
Slimefun.getLocalization().sendMessage(player, "messages.opening-guide");
|
||||
}
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public static void openMainMenu(PlayerProfile profile, SlimefunGuideMode mode, int selectedPage) {
|
||||
SlimefunPlugin.getRegistry().getSlimefunGuide(mode).openMainMenu(profile, selectedPage);
|
||||
Slimefun.getRegistry().getSlimefunGuide(mode).openMainMenu(profile, selectedPage);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public static void openCategory(PlayerProfile profile, Category category, SlimefunGuideMode mode, int selectedPage) {
|
||||
SlimefunPlugin.getRegistry().getSlimefunGuide(mode).openCategory(profile, category, selectedPage);
|
||||
public static void openCategory(PlayerProfile profile, ItemGroup category, SlimefunGuideMode mode, int selectedPage) {
|
||||
Slimefun.getRegistry().getSlimefunGuide(mode).openItemGroup(profile, category, selectedPage);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public static void openSearch(PlayerProfile profile, String input, SlimefunGuideMode mode, boolean addToHistory) {
|
||||
SlimefunGuideImplementation guide = SlimefunPlugin.getRegistry().getSlimefunGuide(mode);
|
||||
SlimefunGuideImplementation guide = Slimefun.getRegistry().getSlimefunGuide(mode);
|
||||
guide.openSearch(profile, input, addToHistory);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public static void displayItem(PlayerProfile profile, ItemStack item, boolean addToHistory) {
|
||||
SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory);
|
||||
Slimefun.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, 0, addToHistory);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public static void displayItem(PlayerProfile profile, SlimefunItem item, boolean addToHistory) {
|
||||
SlimefunPlugin.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
|
||||
Slimefun.getRegistry().getSlimefunGuide(SlimefunGuideMode.SURVIVAL_MODE).displayItem(profile, item, addToHistory);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -9,13 +9,13 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.options.SlimefunGuideSettings;
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.guide.SurvivalSlimefunGuide;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
|
||||
/**
|
||||
* This interface is used for the different implementations that add behaviour
|
||||
@ -52,7 +52,7 @@ public interface SlimefunGuideImplementation {
|
||||
void openMainMenu(PlayerProfile profile, int page);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
void openCategory(PlayerProfile profile, Category category, int page);
|
||||
void openItemGroup(PlayerProfile profile, ItemGroup group, int page);
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
void openSearch(PlayerProfile profile, String input, boolean addToHistory);
|
||||
@ -67,12 +67,12 @@ public interface SlimefunGuideImplementation {
|
||||
default void unlockItem(Player p, SlimefunItem sfitem, Consumer<Player> callback) {
|
||||
Research research = sfitem.getResearch();
|
||||
|
||||
if (p.getGameMode() == GameMode.CREATIVE && SlimefunPlugin.getRegistry().isFreeCreativeResearchingEnabled()) {
|
||||
if (p.getGameMode() == GameMode.CREATIVE && Slimefun.getRegistry().isFreeCreativeResearchingEnabled()) {
|
||||
research.unlock(p, true, callback);
|
||||
} else {
|
||||
p.setLevel(p.getLevel() - research.getCost());
|
||||
|
||||
boolean skipLearningAnimation = SlimefunPlugin.getRegistry().isLearningAnimationDisabled() || !SlimefunGuideSettings.hasLearningAnimationEnabled(p);
|
||||
boolean skipLearningAnimation = Slimefun.getRegistry().isLearningAnimationDisabled() || !SlimefunGuideSettings.hasLearningAnimationEnabled(p);
|
||||
research.unlock(p, skipLearningAnimation, callback);
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
package io.github.thebusybiscuit.slimefun4.core.guide;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ChestMenu;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
/**
|
||||
* This enum holds the different designs a {@link SlimefunGuide} can have.
|
||||
|
@ -11,14 +11,15 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.common.ChatColors;
|
||||
import io.github.bakedlibs.dough.common.CommonPatterns;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.github.Contributor;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
/**
|
||||
@ -32,20 +33,20 @@ final class ContributorsMenu {
|
||||
private ContributorsMenu() {}
|
||||
|
||||
public static void open(Player p, int page) {
|
||||
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.credits"));
|
||||
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.credits"));
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F));
|
||||
|
||||
ChestMenuUtils.drawBackground(menu, 0, 2, 3, 4, 5, 6, 7, 8, 45, 47, 48, 49, 50, 51, 53);
|
||||
|
||||
menu.addItem(1, new CustomItem(ChestMenuUtils.getBackButton(p, "", "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.settings"))));
|
||||
menu.addItem(1, new CustomItemStack(ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings"))));
|
||||
menu.addMenuClickHandler(1, (pl, slot, item, action) -> {
|
||||
SlimefunGuideSettings.openSettings(pl, p.getInventory().getItemInMainHand());
|
||||
return false;
|
||||
});
|
||||
|
||||
List<Contributor> contributors = new ArrayList<>(SlimefunPlugin.getGitHubService().getContributors().values());
|
||||
List<Contributor> contributors = new ArrayList<>(Slimefun.getGitHubService().getContributors().values());
|
||||
contributors.sort(Comparator.comparingInt(Contributor::getPosition));
|
||||
|
||||
for (int i = page * 36; i < contributors.size() && i < (page + 1) * 36; i++) {
|
||||
@ -98,16 +99,16 @@ final class ContributorsMenu {
|
||||
String info = entry.getKey();
|
||||
|
||||
if (!info.startsWith("&")) {
|
||||
String[] segments = PatternUtils.COMMA.split(info);
|
||||
info = SlimefunPlugin.getLocalization().getMessage(p, "guide.credits.roles." + segments[0]);
|
||||
String[] segments = CommonPatterns.COMMA.split(info);
|
||||
info = Slimefun.getLocalization().getMessage(p, "guide.credits.roles." + segments[0]);
|
||||
|
||||
if (segments.length == 2) {
|
||||
info += " &7(" + SlimefunPlugin.getLocalization().getMessage(p, "languages." + segments[1]) + ')';
|
||||
info += " &7(" + Slimefun.getLocalization().getMessage(p, "languages." + segments[1]) + ')';
|
||||
}
|
||||
}
|
||||
|
||||
if (entry.getValue() > 0) {
|
||||
String commits = SlimefunPlugin.getLocalization().getMessage(p, "guide.credits." + (entry.getValue() > 1 ? "commits" : "commit"));
|
||||
String commits = Slimefun.getLocalization().getMessage(p, "guide.credits." + (entry.getValue() > 1 ? "commits" : "commit"));
|
||||
|
||||
info += " &7(" + entry.getValue() + ' ' + commits + ')';
|
||||
}
|
||||
@ -117,7 +118,7 @@ final class ContributorsMenu {
|
||||
|
||||
if (contributor.getProfile() != null) {
|
||||
lore.add("");
|
||||
lore.add(ChatColors.color("&7\u21E8 &e") + SlimefunPlugin.getLocalization().getMessage(p, "guide.credits.profile-link"));
|
||||
lore.add(ChatColors.color("&7\u21E8 &e") + Slimefun.getLocalization().getMessage(p, "guide.credits.profile-link"));
|
||||
}
|
||||
|
||||
meta.setLore(lore);
|
||||
|
@ -7,28 +7,28 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
class FireworksOption implements SlimefunGuideOption<Boolean> {
|
||||
|
||||
@Override
|
||||
public SlimefunAddon getAddon() {
|
||||
return SlimefunPlugin.instance();
|
||||
return Slimefun.instance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return new NamespacedKey(SlimefunPlugin.instance(), "research_fireworks");
|
||||
return new NamespacedKey(Slimefun.instance(), "research_fireworks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
||||
if (SlimefunPlugin.getRegistry().isResearchFireworkEnabled()) {
|
||||
if (Slimefun.getRegistry().isResearchFireworkEnabled()) {
|
||||
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");
|
||||
ItemStack item = new CustomItemStack(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 {
|
||||
return Optional.empty();
|
||||
|
@ -17,7 +17,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
@ -26,13 +26,13 @@ class GuideModeOption implements SlimefunGuideOption<SlimefunGuideMode> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public SlimefunAddon getAddon() {
|
||||
return SlimefunPlugin.instance();
|
||||
return Slimefun.instance();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return new NamespacedKey(SlimefunPlugin.instance(), "guide_mode");
|
||||
return new NamespacedKey(Slimefun.instance(), "guide_mode");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -10,10 +10,10 @@ import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
|
||||
/**
|
||||
* {@link LearningAnimationOption} represents a setting in the Slimefun guide book.
|
||||
@ -27,28 +27,28 @@ class LearningAnimationOption implements SlimefunGuideOption<Boolean> {
|
||||
@Nonnull
|
||||
@Override
|
||||
public SlimefunAddon getAddon() {
|
||||
return SlimefunPlugin.instance();
|
||||
return Slimefun.instance();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return new NamespacedKey(SlimefunPlugin.instance(), "research_learning_animation");
|
||||
return new NamespacedKey(Slimefun.instance(), "research_learning_animation");
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public Optional<ItemStack> getDisplayItem(@Nonnull Player p, @Nonnull ItemStack guide) {
|
||||
if (SlimefunPlugin.getRegistry().isLearningAnimationDisabled()) {
|
||||
if (Slimefun.getRegistry().isLearningAnimationDisabled()) {
|
||||
return Optional.empty();
|
||||
} else {
|
||||
boolean enabled = getSelectedOption(p, guide).orElse(true);
|
||||
String optionState = enabled ? "enabled" : "disabled";
|
||||
List<String> lore = SlimefunPlugin.getLocalization().getMessages(p, "guide.options.learning-animation." + optionState + ".text");
|
||||
List<String> lore = Slimefun.getLocalization().getMessages(p, "guide.options.learning-animation." + optionState + ".text");
|
||||
lore.add("");
|
||||
lore.add("&7\u21E8 " + SlimefunPlugin.getLocalization().getMessage(p, "guide.options.learning-animation." + optionState + ".click"));
|
||||
lore.add("&7\u21E8 " + Slimefun.getLocalization().getMessage(p, "guide.options.learning-animation." + optionState + ".click"));
|
||||
|
||||
ItemStack item = new CustomItem(enabled ? Material.MAP : Material.PAPER, lore);
|
||||
ItemStack item = new CustomItemStack(enabled ? Material.MAP : Material.PAPER, lore);
|
||||
return Optional.of(item);
|
||||
}
|
||||
}
|
||||
|
@ -10,45 +10,46 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerLanguageChangeEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
class PlayerLanguageOption implements SlimefunGuideOption<String> {
|
||||
|
||||
@Override
|
||||
public SlimefunAddon getAddon() {
|
||||
return SlimefunPlugin.instance();
|
||||
return Slimefun.instance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return SlimefunPlugin.getLocalization().getKey();
|
||||
return Slimefun.getLocalization().getKey();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> getDisplayItem(Player p, ItemStack guide) {
|
||||
if (SlimefunPlugin.getLocalization().isEnabled()) {
|
||||
Language language = SlimefunPlugin.getLocalization().getLanguage(p);
|
||||
String languageName = language.isDefault() ? (SlimefunPlugin.getLocalization().getMessage(p, "languages.default") + ChatColor.DARK_GRAY + " (" + language.getName(p) + ")") : SlimefunPlugin.getLocalization().getMessage(p, "languages." + language.getId());
|
||||
if (Slimefun.getLocalization().isEnabled()) {
|
||||
Language language = Slimefun.getLocalization().getLanguage(p);
|
||||
String languageName = language.isDefault() ? (Slimefun.getLocalization().getMessage(p, "languages.default") + ChatColor.DARK_GRAY + " (" + language.getName(p) + ")") : Slimefun.getLocalization().getMessage(p, "languages." + language.getId());
|
||||
|
||||
List<String> lore = new ArrayList<>();
|
||||
lore.add("");
|
||||
lore.add("&e&o" + SlimefunPlugin.getLocalization().getMessage(p, "guide.work-in-progress"));
|
||||
lore.add("&e&o" + Slimefun.getLocalization().getMessage(p, "guide.work-in-progress"));
|
||||
lore.add("");
|
||||
lore.addAll(SlimefunPlugin.getLocalization().getMessages(p, "guide.languages.description", msg -> msg.replace("%contributors%", String.valueOf(SlimefunPlugin.getGitHubService().getContributors().size()))));
|
||||
lore.addAll(Slimefun.getLocalization().getMessages(p, "guide.languages.description", msg -> msg.replace("%contributors%", String.valueOf(Slimefun.getGitHubService().getContributors().size()))));
|
||||
lore.add("");
|
||||
lore.add("&7\u21E8 &e" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.change"));
|
||||
lore.add("&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.change"));
|
||||
|
||||
ItemStack item = new CustomItem(language.getItem(), "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0]));
|
||||
ItemStack item = new CustomItemStack(language.getItem(), "&7" + Slimefun.getLocalization().getMessage(p, "guide.languages.selected-language") + " &a" + languageName, lore.toArray(new String[0]));
|
||||
return Optional.of(item);
|
||||
} else {
|
||||
return Optional.empty();
|
||||
@ -62,7 +63,7 @@ class PlayerLanguageOption implements SlimefunGuideOption<String> {
|
||||
|
||||
@Override
|
||||
public Optional<String> getSelectedOption(Player p, ItemStack guide) {
|
||||
return Optional.of(SlimefunPlugin.getLocalization().getLanguage(p).getId());
|
||||
return Optional.of(Slimefun.getLocalization().getLanguage(p).getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,19 +76,19 @@ class PlayerLanguageOption implements SlimefunGuideOption<String> {
|
||||
}
|
||||
|
||||
private void openLanguageSelection(Player p, ItemStack guide) {
|
||||
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.languages"));
|
||||
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.languages"));
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F));
|
||||
|
||||
for (int i = 0; i < 9; i++) {
|
||||
if (i == 1) {
|
||||
menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + SlimefunPlugin.getLocalization().getMessage(p, "guide.back.settings")), (pl, slot, item, action) -> {
|
||||
menu.addItem(1, ChestMenuUtils.getBackButton(p, "", "&7" + Slimefun.getLocalization().getMessage(p, "guide.back.settings")), (pl, slot, item, action) -> {
|
||||
SlimefunGuideSettings.openSettings(pl, guide);
|
||||
return false;
|
||||
});
|
||||
} else if (i == 7) {
|
||||
menu.addItem(7, new 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) -> {
|
||||
menu.addItem(7, new CustomItemStack(SlimefunUtils.getCustomHead(HeadTexture.ADD_NEW_LANGUAGE.getTexture()), Slimefun.getLocalization().getMessage(p, "guide.languages.translations.name"), "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.translations.lore")), (pl, slot, item, action) -> {
|
||||
ChatUtils.sendURL(pl, "https://github.com/Slimefun/Slimefun4/wiki/Translating-Slimefun");
|
||||
pl.closeInventory();
|
||||
return false;
|
||||
@ -97,14 +98,14 @@ class PlayerLanguageOption implements SlimefunGuideOption<String> {
|
||||
}
|
||||
}
|
||||
|
||||
Language defaultLanguage = SlimefunPlugin.getLocalization().getDefaultLanguage();
|
||||
String defaultLanguageString = SlimefunPlugin.getLocalization().getMessage(p, "languages.default");
|
||||
Language defaultLanguage = Slimefun.getLocalization().getDefaultLanguage();
|
||||
String defaultLanguageString = Slimefun.getLocalization().getMessage(p, "languages.default");
|
||||
|
||||
menu.addItem(9, new CustomItem(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> {
|
||||
SlimefunPlugin.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, SlimefunPlugin.getLocalization().getLanguage(pl), defaultLanguage));
|
||||
menu.addItem(9, new CustomItemStack(defaultLanguage.getItem(), ChatColor.GRAY + defaultLanguageString + ChatColor.DARK_GRAY + " (" + defaultLanguage.getName(p) + ")", "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select-default")), (pl, i, item, action) -> {
|
||||
Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), defaultLanguage));
|
||||
setSelectedOption(pl, guide, null);
|
||||
|
||||
SlimefunPlugin.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString));
|
||||
Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", defaultLanguageString));
|
||||
|
||||
SlimefunGuideSettings.openSettings(pl, guide);
|
||||
return false;
|
||||
@ -112,13 +113,13 @@ class PlayerLanguageOption implements SlimefunGuideOption<String> {
|
||||
|
||||
int slot = 10;
|
||||
|
||||
for (Language language : SlimefunPlugin.getLocalization().getLanguages()) {
|
||||
menu.addItem(slot, new CustomItem(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + SlimefunPlugin.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> {
|
||||
SlimefunPlugin.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, SlimefunPlugin.getLocalization().getLanguage(pl), language));
|
||||
for (Language language : Slimefun.getLocalization().getLanguages()) {
|
||||
menu.addItem(slot, new CustomItemStack(language.getItem(), ChatColor.GREEN + language.getName(p), "&b" + language.getTranslationProgress() + '%', "", "&7\u21E8 &e" + Slimefun.getLocalization().getMessage(p, "guide.languages.select")), (pl, i, item, action) -> {
|
||||
Slimefun.instance().getServer().getPluginManager().callEvent(new PlayerLanguageChangeEvent(pl, Slimefun.getLocalization().getLanguage(pl), language));
|
||||
setSelectedOption(pl, guide, language.getId());
|
||||
|
||||
String name = language.getName(pl);
|
||||
SlimefunPlugin.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name));
|
||||
Slimefun.getLocalization().sendMessage(pl, "guide.languages.updated", msg -> msg.replace("%lang%", name));
|
||||
|
||||
SlimefunGuideSettings.openSettings(pl, guide);
|
||||
return false;
|
||||
|
@ -14,18 +14,19 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.bakedlibs.dough.items.CustomItemStack;
|
||||
import io.github.thebusybiscuit.slimefun4.api.researches.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
|
||||
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideMode;
|
||||
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.LocalizationService;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.github.GitHubService;
|
||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChatUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.NumberUtils;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
|
||||
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
|
||||
|
||||
/**
|
||||
@ -59,7 +60,7 @@ public final class SlimefunGuideSettings {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public static void openSettings(Player p, ItemStack guide) {
|
||||
ChestMenu menu = new ChestMenu(SlimefunPlugin.getLocalization().getMessage(p, "guide.title.settings"));
|
||||
ChestMenu menu = new ChestMenu(Slimefun.getLocalization().getMessage(p, "guide.title.settings"));
|
||||
|
||||
menu.setEmptySlotsClickable(false);
|
||||
menu.addMenuOpeningHandler(pl -> pl.playSound(pl.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 0.7F, 0.7F));
|
||||
@ -74,10 +75,10 @@ public final class SlimefunGuideSettings {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
private static void addHeader(Player p, ChestMenu menu, ItemStack guide) {
|
||||
LocalizationService locale = SlimefunPlugin.getLocalization();
|
||||
LocalizationService locale = Slimefun.getLocalization();
|
||||
|
||||
// @formatter:off
|
||||
menu.addItem(0, new CustomItem(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE),
|
||||
menu.addItem(0, new CustomItemStack(SlimefunGuide.getItem(SlimefunGuideMode.SURVIVAL_MODE),
|
||||
"&e\u21E6 " + locale.getMessage(p, "guide.back.title"),
|
||||
"",
|
||||
"&7" + locale.getMessage(p, "guide.back.guide")
|
||||
@ -89,7 +90,7 @@ public final class SlimefunGuideSettings {
|
||||
return false;
|
||||
});
|
||||
|
||||
GitHubService github = SlimefunPlugin.getGitHubService();
|
||||
GitHubService github = Slimefun.getGitHubService();
|
||||
|
||||
List<String> contributorsLore = new ArrayList<>();
|
||||
contributorsLore.add("");
|
||||
@ -98,7 +99,7 @@ public final class SlimefunGuideSettings {
|
||||
contributorsLore.add("&7\u21E8 &e" + locale.getMessage(p, "guide.credits.open"));
|
||||
|
||||
// @formatter:off
|
||||
menu.addItem(2, new CustomItem(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"),
|
||||
menu.addItem(2, new CustomItemStack(SlimefunUtils.getCustomHead("e952d2b3f351a6b0487cc59db31bf5f2641133e5ba0006b18576e996a0293e52"),
|
||||
"&c" + locale.getMessage(p, "guide.title.credits"),
|
||||
contributorsLore.toArray(new String[0])
|
||||
));
|
||||
@ -110,18 +111,18 @@ public final class SlimefunGuideSettings {
|
||||
});
|
||||
|
||||
// @formatter:off
|
||||
menu.addItem(4, new CustomItem(Material.WRITABLE_BOOK,
|
||||
menu.addItem(4, new CustomItemStack(Material.WRITABLE_BOOK,
|
||||
ChatColor.GREEN + locale.getMessage(p, "guide.title.versions"),
|
||||
"&7&o" + locale.getMessage(p, "guide.tooltips.versions-notice"),
|
||||
"",
|
||||
"&fMinecraft: &a" + Bukkit.getBukkitVersion(),
|
||||
"&fSlimefun: &a" + SlimefunPlugin.getVersion()),
|
||||
"&fSlimefun: &a" + Slimefun.getVersion()),
|
||||
ChestMenuUtils.getEmptyClickHandler()
|
||||
);
|
||||
// @formatter:on
|
||||
|
||||
// @formatter:off
|
||||
menu.addItem(6, new CustomItem(Material.COMPARATOR,
|
||||
menu.addItem(6, new CustomItemStack(Material.COMPARATOR,
|
||||
"&e" + locale.getMessage(p, "guide.title.source"),
|
||||
"", "&7Last Activity: &a" + NumberUtils.getElapsedTime(github.getLastUpdate()) + " ago",
|
||||
"&7Forks: &e" + github.getForks(),
|
||||
@ -143,7 +144,7 @@ public final class SlimefunGuideSettings {
|
||||
});
|
||||
|
||||
// @formatter:off
|
||||
menu.addItem(8, new CustomItem(Material.KNOWLEDGE_BOOK,
|
||||
menu.addItem(8, new CustomItemStack(Material.KNOWLEDGE_BOOK,
|
||||
"&3" + locale.getMessage(p, "guide.title.wiki"),
|
||||
"", "&7Do you need help with an Item or machine?",
|
||||
"&7You cannot figure out what to do?",
|
||||
@ -161,14 +162,14 @@ public final class SlimefunGuideSettings {
|
||||
});
|
||||
|
||||
// @formatter:off
|
||||
menu.addItem(47, new CustomItem(Material.BOOKSHELF,
|
||||
menu.addItem(47, new CustomItemStack(Material.BOOKSHELF,
|
||||
"&3" + locale.getMessage(p, "guide.title.addons"),
|
||||
"",
|
||||
"&7Slimefun is huge. But its addons are what makes",
|
||||
"&7this plugin truly shine. Go check them out, some",
|
||||
"&7of them may be exactly what you were missing out on!",
|
||||
"",
|
||||
"&7Installed on this Server: &b" + SlimefunPlugin.getInstalledAddons().size(),
|
||||
"&7Installed on this Server: &b" + Slimefun.getInstalledAddons().size(),
|
||||
"",
|
||||
"&7\u21E8 &eClick to see all available addons for Slimefun4"
|
||||
));
|
||||
@ -180,9 +181,9 @@ public final class SlimefunGuideSettings {
|
||||
return false;
|
||||
});
|
||||
|
||||
if (SlimefunPlugin.getUpdater().getBranch().isOfficial()) {
|
||||
if (Slimefun.getUpdater().getBranch().isOfficial()) {
|
||||
// @formatter:off
|
||||
menu.addItem(49, new CustomItem(Material.REDSTONE_TORCH,
|
||||
menu.addItem(49, new CustomItemStack(Material.REDSTONE_TORCH,
|
||||
"&4" + locale.getMessage(p, "guide.title.bugs"),
|
||||
"",
|
||||
"&7&oBug reports have to be made in English!",
|
||||
@ -203,7 +204,7 @@ public final class SlimefunGuideSettings {
|
||||
menu.addItem(49, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler());
|
||||
}
|
||||
|
||||
menu.addItem(51, new CustomItem(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> {
|
||||
menu.addItem(51, new CustomItemStack(Material.TOTEM_OF_UNDYING, ChatColor.RED + locale.getMessage(p, "guide.work-in-progress")), (pl, slot, item, action) -> {
|
||||
// Add something here
|
||||
return false;
|
||||
});
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.AndroidMineEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.MinerAndroid;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
/**
|
||||
* The {@link BlockBreakHandler} is called when a {@link Block} is broken
|
||||
|
@ -8,10 +8,10 @@ import org.bukkit.block.Dispenser;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
/**
|
||||
* This {@link ItemHandler} is triggered when the {@link SlimefunItem} it was assigned to
|
||||
|
@ -7,9 +7,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.BlockPlacer;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
/**
|
||||
* This {@link ItemHandler} is called whenever a {@link Block} was placed.
|
||||
|
@ -4,9 +4,9 @@ import java.util.Optional;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.api.exceptions.IncompatibleItemHandlerException;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.ItemHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BlockUseHandler extends ItemHandler {
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user