1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-20 11:45:51 +00:00

Merge branch 'master' into MoreTalismans

This commit is contained in:
TheBusyBiscuit 2020-10-30 22:54:36 +01:00 committed by GitHub
commit 192258fb74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
114 changed files with 2408 additions and 1015 deletions

View File

@ -6,10 +6,13 @@ yaml-files:
rules:
## A warning is sufficient here
line-length:
max: 180
level: warning
## Don't warn for line lengths
line-length: disable
truthy:
allowed-values: ['true', 'false']
## We don't want it to trigger for the 'on' in our workflows
check-keys: false
## We don't need indentation warnings
indentation: disable

View File

@ -22,7 +22,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@master
with:

View File

@ -16,7 +16,7 @@ jobs:
steps:
- name: TOC Generator
uses: technote-space/toc-generator@v2.4.0
uses: technote-space/toc-generator@v2.6.1
with:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
TARGET_PATHS: 'CHANGELOG.md'

View File

@ -6,7 +6,7 @@ on:
- master
jobs:
build:
check:
name: URL Checker
runs-on: ubuntu-latest
@ -17,7 +17,7 @@ jobs:
with:
git_path: https://github.com/Slimefun/Slimefun4
file_types: .md,.java,.yml
print_all: False
print_all: false
retry_count: 2
## These URLs will always be correct, even if their services may be offline right now
white_listed_patterns: http://textures.minecraft.net/texture/,https://pastebin.com/,https://www.spigotmc.org/threads/spigot-bungeecord-1-16-1.447405/#post-3852349,https://gitlocalize.com/repo/3841

View File

@ -16,8 +16,8 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v1
uses: actions/checkout@v2
- name: YAML Linter
uses: ibiqlik/action-yamllint@v1.0.0
uses: ibiqlik/action-yamllint@v2.0.0
with:
config_file: '.github/configs/yaml-linter.yml'

View File

@ -2,7 +2,8 @@
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of contents**
- [Release Candidate 17 (TBD)](#release-candidate-17-tbd)
- [Release Candidate 18 (TBD)](#release-candidate-18-tbd)
- [Release Candidate 17 (17 Oct 2020)](#release-candidate-17-17-oct-2020)
- [Release Candidate 16 (07 Sep 2020)](#release-candidate-16-07-sep-2020)
- [Release Candidate 15 (01 Aug 2020)](#release-candidate-15-01-aug-2020)
- [Release Candidate 14 (12 Jul 2020)](#release-candidate-14-12-jul-2020)
@ -22,7 +23,33 @@
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Release Candidate 17 (TBD)
## Release Candidate 18 (TBD)
#### Additions
#### Changes
* Removed 1.13 support
* Cooling Units can no longer be placed down
* Heating Coils can no longer be placed down
* Electric Motors can no longer be placed down
* Cargo Motors can no longer be placed down
* Magnets can no longer be placed down
* Electromagnets can no longer be placed down
#### Fixes
* Fixed #2448
* Fixed #2470
* Fixed #2478
* Fixed #2493
* Fixed a missing slot in the contributors menu
* Fixed color codes in script downloading screen
* Fixed #2505
* Fixed contributors not showing correctly
* Fixed #2469
* Fixed #2509
* Fixed #2499
## Release Candidate 17 (17 Oct 2020)
#### Additions
* Added /sf charge
@ -40,6 +67,10 @@
* (API) Added custom tags for developers
* The range of the Seeker Pickaxe is now configurable
* Added Energy Connector
* Blackstone can now be turned into lava using a Crucible
* Basalt can now be turned into lava using a Crucible
* Added "Tainted Sheep" (You can dye a Sheep using Strange Nether Goo)
* Added mcMMO support/integration
#### Changes
* Improved Auto-Updater (Multi-Threading and more)
@ -81,6 +112,14 @@
* Fixed #2450
* Fixed Steel Thrusters being used to milk cows
* Fixed #2424
* Fixed #2468
* Fixed #2414
* Fixed #2454
* Fixed #2457
* Fixed #2411
* Fixed #2423
* Fixed #2452
* Fixed a dupe bug with mcMMO
## Release Candidate 16 (07 Sep 2020)
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16

View File

@ -32,7 +32,7 @@ Here is a full summary of the differences between the two different versions of
| | development (latest) | "stable" |
| ------------------ | -------- | -------- |
| **Minecraft version(s)** | :video_game: **1.13.\* - 1.16.\*** | :video_game: **1.13.\* - 1.16.\*** |
| **Minecraft version(s)** | :video_game: **1.14.\* - 1.16.\*** | :video_game: **1.13.\* - 1.16.\*** |
| **automatic updates** | :heavy_check_mark: | :heavy_check_mark: |
| **frequent updates** | :heavy_check_mark: | :x: |
| **latest content** | :heavy_check_mark: | :x: |

36
pom.xml
View File

@ -64,6 +64,10 @@
<id>worldedit-repo</id>
<url>https://maven.sk89q.com/repo/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
<repository>
<id>placeholderapi-repo</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
@ -311,7 +315,7 @@
<dependency>
<groupId>com.github.seeseemelk</groupId>
<artifactId>MockBukkit-v1.16</artifactId>
<version>0.10.2</version>
<version>0.13.0</version>
<scope>test</scope>
<exclusions>
<exclusion>
@ -325,7 +329,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.5.13</version>
<version>3.6.0</version>
<scope>test</scope>
</dependency>
@ -345,7 +349,7 @@
<dependency>
<groupId>com.konghq</groupId>
<artifactId>unirest-java</artifactId>
<version>3.11.01</version>
<version>3.11.02</version>
<scope>compile</scope>
<exclusions>
<exclusion>
@ -368,6 +372,32 @@
<groupId>de.schlichtherle</groupId>
<artifactId>truezip</artifactId>
</exclusion>
<exclusion>
<groupId>net.java.truevfs</groupId>
<artifactId>truevfs-profile-default_2.13</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.gmail.nossr50.mcMMO</groupId>
<artifactId>mcMMO</artifactId>
<version>2.1.150</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<!-- We use javax.annotation instead. Excluding this -->
<!-- prevents us from using inconsistent annotations -->
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-core</artifactId>
</exclusion>
<exclusion>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>

View File

@ -14,12 +14,6 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
*/
public enum MinecraftVersion {
/**
* This constant represents Minecraft (Java Edition) Version 1.14
* (The Update Aquatic)
*/
MINECRAFT_1_13("1.13.x"),
/**
* This constant represents Minecraft (Java Edition) Version 1.14
* (The "Village &amp; Pillage" Update)

View File

@ -22,14 +22,12 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.collections.KeyMap;
import io.github.thebusybiscuit.cscorelib2.config.Config;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideImplementation;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
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.guide.BookSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.guide.CheatSheetSlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.guide.ChestSlimefunGuide;
@ -100,7 +98,7 @@ public final class SlimefunRegistry {
researchRanks.addAll(cfg.getStringList("research-ranks"));
backwardsCompatibility = cfg.getBoolean("options.backwards-compatibility") || SlimefunPlugin.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_14);
backwardsCompatibility = cfg.getBoolean("options.backwards-compatibility");
freeCreativeResearches = cfg.getBoolean("researches.free-in-creative-mode");
researchFireworks = cfg.getBoolean("researches.enable-fireworks");
logDuplicateBlockEntries = cfg.getBoolean("options.log-duplicate-block-entries");

View File

@ -13,7 +13,6 @@ import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.PatternUtils;
import net.md_5.bungee.api.ChatColor;
@ -39,9 +38,7 @@ final class RechargeableHelper {
BigDecimal decimal = BigDecimal.valueOf(charge).setScale(2, RoundingMode.HALF_UP);
float value = decimal.floatValue();
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
meta.getPersistentDataContainer().set(CHARGE_KEY, PersistentDataType.FLOAT, value);
}
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();
for (int i = 0; i < lore.size(); i++) {
@ -59,14 +56,12 @@ final class RechargeableHelper {
}
static float getCharge(@Nonnull ItemMeta meta) {
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
Float value = meta.getPersistentDataContainer().get(CHARGE_KEY, PersistentDataType.FLOAT);
// If persistent data is available, we just return this value
if (value != null) {
return value;
}
}
// If no persistent data exists, we will just fall back to the lore
if (meta.hasLore()) {

View File

@ -37,7 +37,7 @@ final class ContributorsMenu {
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, 52);
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.addMenuClickHandler(1, (pl, slot, item, action) -> {

View File

@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
@ -41,12 +40,9 @@ public final class SlimefunGuideSettings {
static {
options.add(new GuideLayoutOption());
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
options.add(new FireworksOption());
options.add(new PlayerLanguageOption());
}
}
private SlimefunGuideSettings() {}

View File

@ -41,10 +41,8 @@ public class MultiBlock {
SUPPORTED_TAGS.add(Tag.LOGS);
SUPPORTED_TAGS.add(Tag.WOODEN_TRAPDOORS);
SUPPORTED_TAGS.add(Tag.WOODEN_SLABS);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
SUPPORTED_TAGS.add(Tag.WOODEN_FENCES);
}
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
SUPPORTED_TAGS.add(Tag.FIRE);
}

View File

@ -18,10 +18,10 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.blocks.BlockPosition;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import io.papermc.lib.PaperLib;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
@ -54,6 +54,10 @@ final class CargoUtils {
Material type = block.getType();
if (SlimefunTag.SHULKER_BOXES.isTagged(type)) {
return true;
}
switch (type) {
case CHEST:
case TRAPPED_CHEST:
@ -62,29 +66,14 @@ final class CargoUtils {
case DROPPER:
case HOPPER:
case BREWING_STAND:
case SHULKER_BOX:
return true;
default:
break;
}
if (type.name().endsWith("_SHULKER_BOX")) {
return true;
}
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
switch (type) {
case BARREL:
case BLAST_FURNACE:
case SMOKER:
return true;
default:
break;
}
}
return false;
}
}
static int[] getInputSlotRange(@Nonnull Inventory inv, @Nullable ItemStack item) {
if (inv instanceof FurnaceInventory) {

View File

@ -2,6 +2,10 @@ package io.github.thebusybiscuit.slimefun4.core.services;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang.Validate;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@ -11,8 +15,8 @@ import org.bukkit.block.TileState;
import org.bukkit.persistence.PersistentDataHolder;
import org.bukkit.plugin.Plugin;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.papermc.lib.PaperLib;
import io.papermc.lib.features.blockstatesnapshot.BlockStateSnapshotResult;
/**
* The {@link BlockDataService} is similar to the {@link CustomItemDataService},
@ -27,7 +31,17 @@ public class BlockDataService implements PersistentDataService, Keyed {
private final NamespacedKey namespacedKey;
public BlockDataService(Plugin plugin, String key) {
/**
* This creates a new {@link BlockDataService} for the given {@link Plugin}.
* The {@link Plugin} and key will together form a {@link NamespacedKey} used to store
* data on a {@link TileState}.
*
* @param plugin
* The {@link Plugin} responsible for this service
* @param key
* The key under which to store data
*/
public BlockDataService(@Nonnull Plugin plugin, @Nonnull String key) {
namespacedKey = new NamespacedKey(plugin, key);
}
@ -44,14 +58,21 @@ public class BlockDataService implements PersistentDataService, Keyed {
* @param value
* The value to store
*/
public void setBlockData(Block b, String value) {
BlockState state = b.getState();
public void setBlockData(@Nonnull Block b, @Nonnull String value) {
Validate.notNull(b, "The block cannot be null!");
Validate.notNull(value, "The value cannot be null!");
BlockStateSnapshotResult result = PaperLib.getBlockState(b, false);
BlockState state = result.getState();
if (state instanceof TileState) {
setString((TileState) state, namespacedKey, value);
if (result.isSnapshot()) {
state.update();
}
}
}
/**
* This method returns the NBT data previously stored inside this {@link Block}.
@ -60,8 +81,10 @@ public class BlockDataService implements PersistentDataService, Keyed {
* The {@link Block} to retrieve data from
* @return The stored value
*/
public Optional<String> getBlockData(Block b) {
BlockState state = b.getState();
public Optional<String> getBlockData(@Nonnull Block b) {
Validate.notNull(b, "The block cannot be null!");
BlockState state = PaperLib.getBlockState(b, false).getState();
if (state instanceof TileState) {
return getString((TileState) state, namespacedKey);
@ -80,12 +103,12 @@ public class BlockDataService implements PersistentDataService, Keyed {
*
* @param type
* The {@link Material} to check for
*
* @return Whether the given {@link Material} is considered a Tile Entity
*/
public boolean isTileEntity(Material type) {
if (type == null || !SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
// We can only store data on Tile Entities in 1.14+
// So we will just return false here in that case.
public boolean isTileEntity(@Nullable Material type) {
if (type == null || type.isAir()) {
// Cannot store data on air
return false;
}
@ -108,8 +131,10 @@ public class BlockDataService implements PersistentDataService, Keyed {
case BARREL:
case SPAWNER:
case BEACON:
// All of the above Materials are Tile Entities
return true;
default:
// Otherwise we assume they're not Tile Entities
return false;
}
}

View File

@ -2,6 +2,10 @@ package io.github.thebusybiscuit.slimefun4.core.services;
import java.util.Optional;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.apache.commons.lang.Validate;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
@ -35,7 +39,7 @@ public class CustomItemDataService implements PersistentDataService, Keyed {
* @param key
* The key under which to store data
*/
public CustomItemDataService(Plugin plugin, String key) {
public CustomItemDataService(@Nonnull Plugin plugin, @Nonnull String key) {
// Null-Validation is performed in the NamespacedKey constructor
namespacedKey = new NamespacedKey(plugin, key);
}
@ -45,13 +49,37 @@ public class CustomItemDataService implements PersistentDataService, Keyed {
return namespacedKey;
}
public void setItemData(ItemStack item, String id) {
/**
* This method stores the given id on the provided {@link ItemStack} via
* persistent data.
*
* @param item
* The {@link ItemStack} to store data on
* @param id
* The id to store on the {@link ItemStack}
*/
public void setItemData(@Nonnull ItemStack item, @Nonnull String id) {
Validate.notNull(item, "The Item cannot be null!");
Validate.notNull(id, "Cannot store null on an Item!");
ItemMeta im = item.getItemMeta();
setItemData(im, id);
item.setItemMeta(im);
}
public void setItemData(ItemMeta im, String id) {
/**
* This method stores the given id on the provided {@link ItemMeta} via
* persistent data.
*
* @param im
* The {@link ItemMeta} to store data on
* @param id
* The id to store on the {@link ItemMeta}
*/
public void setItemData(@Nonnull ItemMeta im, @Nonnull String id) {
Validate.notNull(im, "The ItemMeta cannot be null!");
Validate.notNull(id, "Cannot store null on an ItemMeta!");
setString(im, namespacedKey, id);
}
@ -65,7 +93,8 @@ public class CustomItemDataService implements PersistentDataService, Keyed {
*
* @return An {@link Optional} describing the result
*/
public Optional<String> getItemData(ItemStack item) {
@Nonnull
public Optional<String> getItemData(@Nullable ItemStack item) {
if (item == null || item.getType() == Material.AIR || !item.hasItemMeta()) {
return Optional.empty();
}
@ -82,7 +111,10 @@ public class CustomItemDataService implements PersistentDataService, Keyed {
*
* @return An {@link Optional} describing the result
*/
public Optional<String> getItemData(ItemMeta meta) {
@Nonnull
public Optional<String> getItemData(@Nonnull ItemMeta meta) {
Validate.notNull(meta, "Cannot read data from null!");
return getString(meta, namespacedKey);
}

View File

@ -10,8 +10,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import io.github.thebusybiscuit.cscorelib2.config.Config;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@ -30,6 +28,12 @@ public class CustomTextureService {
private String version = null;
private boolean modified = false;
/**
* This creates a new {@link CustomTextureService} for the provided {@link Config}
*
* @param config
* The {@link Config} to read custom model data from
*/
public CustomTextureService(@Nonnull Config config) {
this.config = config;
config.getConfiguration().options().header("This file is used to assign items from Slimefun or any of its addons\n" + "the 'CustomModelData' NBT tag. This can be used in conjunction with a custom resource pack\n" + "to give items custom textures.\n0 means there is no data assigned to that item.\n\n" + "There is no official Slimefun resource pack at the moment.");
@ -51,6 +55,8 @@ public class CustomTextureService {
config.setDefaultValue("SLIMEFUN_GUIDE", 0);
config.setDefaultValue("_UI_BACKGROUND", 0);
config.setDefaultValue("_UI_NO_PERMISSION", 0);
config.setDefaultValue("_UI_NOT_RESEARCHED", 0);
config.setDefaultValue("_UI_INPUT_SLOT", 0);
config.setDefaultValue("_UI_OUTPUT_SLOT", 0);
config.setDefaultValue("_UI_BACK", 0);
@ -84,27 +90,62 @@ public class CustomTextureService {
return version;
}
/**
* This returns true if any custom model data was configured.
* If every item id has no configured custom model data, it will return false.
*
* @return Whether any custom model data was configured
*/
public boolean isActive() {
return modified;
}
/**
* This returns the configured custom model data for a given id.
*
* @param id
* The id to get the data for
*
* @return The configured custom model data
*/
public int getModelData(@Nonnull String id) {
Validate.notNull(id, "Cannot get the ModelData for 'null'");
return config.getInt(id);
}
/**
* This method sets the custom model data for this {@link ItemStack}
* to the value configured for the provided item id.
*
* @param item
* The {@link ItemStack} to set the custom model data for
* @param id
* The id for which to get the configured model data
*/
public void setTexture(@Nonnull ItemStack item, @Nonnull String id) {
Validate.notNull(item, "The Item cannot be null!");
Validate.notNull(id, "Cannot store null on an Item!");
ItemMeta im = item.getItemMeta();
setTexture(im, id);
item.setItemMeta(im);
}
/**
* This method sets the custom model data for this {@link ItemMeta}
* to the value configured for the provided item id.
*
* @param im
* The {@link ItemMeta} to set the custom model data for
* @param id
* The id for which to get the configured model data
*/
public void setTexture(@Nonnull ItemMeta im, @Nonnull String id) {
int data = getModelData(id);
Validate.notNull(im, "The ItemMeta cannot be null!");
Validate.notNull(id, "Cannot store null on an ItemMeta!");
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
int data = getModelData(id);
im.setCustomModelData(data == 0 ? null : data);
}
}
}

View File

@ -34,9 +34,26 @@ import kong.unirest.UnirestException;
*/
public class MetricsService {
/**
* The URL pointing towards the GitHub API.
*/
private static final String API_URL = "https://api.github.com/";
/**
* The Name of our repository
*/
private static final String REPO_NAME = "MetricsModule";
/**
* The URL pointing towards the /releases/ endpoint of our
* Metrics repository
*/
private static final String RELEASES_URL = API_URL + "repos/Slimefun/" + REPO_NAME + "/releases/latest";
/**
* The URL pointing towards the download location for a
* GitHub release of our Metrics repository
*/
private static final String DOWNLOAD_URL = "https://github.com/Slimefun/" + REPO_NAME + "/releases/download";
private final SlimefunPlugin plugin;
@ -48,9 +65,22 @@ public class MetricsService {
private boolean hasDownloadedUpdate = false;
static {
Unirest.config().concurrency(2, 1).setDefaultHeader("User-Agent", "MetricsModule Auto-Updater").setDefaultHeader("Accept", "application/vnd.github.v3+json").enableCookieManagement(false).cookieSpec("ignoreCookies");
// @formatter:off (We want this to stay this nicely aligned :D )
Unirest.config()
.concurrency(2, 1)
.setDefaultHeader("User-Agent", "MetricsModule Auto-Updater")
.setDefaultHeader("Accept", "application/vnd.github.v3+json")
.enableCookieManagement(false)
.cookieSpec("ignoreCookies");
// @formatter:on
}
/**
* This constructs a new instance of our {@link MetricsService}.
*
* @param plugin
* Our {@link SlimefunPlugin} instance
*/
public MetricsService(@Nonnull SlimefunPlugin plugin) {
this.plugin = plugin;
this.parentFolder = new File(plugin.getDataFolder(), "cache" + File.separatorChar + "modules");

View File

@ -7,8 +7,8 @@ import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataHolder;
import org.bukkit.persistence.PersistentDataType;
import io.github.thebusybiscuit.cscorelib2.data.PersistentDataAPI;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
/**
* This interface is used to defer calls to Persistent Data and make sure they are only called
@ -16,23 +16,20 @@ import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
*
* @author TheBusyBiscuit
*
* @deprecated This is redundant, we can use {@link PersistentDataAPI} instead.
*
*/
@Deprecated
interface PersistentDataService {
default void setString(Object obj, NamespacedKey key, String value) {
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) && obj instanceof PersistentDataHolder) {
PersistentDataContainer container = ((PersistentDataHolder) obj).getPersistentDataContainer();
container.set(key, PersistentDataType.STRING, value);
}
}
default Optional<String> getString(Object obj, NamespacedKey key) {
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) && obj instanceof PersistentDataHolder) {
PersistentDataContainer container = ((PersistentDataHolder) obj).getPersistentDataContainer();
return Optional.ofNullable(container.get(key, PersistentDataType.STRING));
}
return Optional.empty();
}
}

View File

@ -16,11 +16,28 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
class ContributionsConnector extends GitHubConnector {
// GitHub Bots that do not count as Contributors
// (includes "invalid-email-address" because it is an invalid contributor)
private static final List<String> blacklist = Arrays.asList("invalid-email-address", "renovate-bot", "TheBusyBot", "ImgBotApp", "imgbot", "imgbot[bot]", "github-actions[bot]", "gitlocalize-app", "gitlocalize-app[bot]", "mt-gitlocalize");
/*
* @formatter:off
* GitHub Bots that do not count as Contributors
* (includes "invalid-email-address" because it is an invalid contributor)
*/
private static final List<String> blacklist = Arrays.asList(
"invalid-email-address",
"renovate-bot",
"TheBusyBot",
"ImgBotApp",
"imgbot",
"imgbot[bot]",
"github-actions[bot]",
"gitlocalize-app",
"gitlocalize-app[bot]",
"mt-gitlocalize"
);
// Matches a GitHub name with a Minecraft name.
/*
* @formatter:on
* Matches a GitHub name with a Minecraft name.
*/
private static final Map<String, String> aliases = new HashMap<>();
// Should probably be switched to UUIDs at some point...
@ -82,8 +99,16 @@ class ContributionsConnector extends GitHubConnector {
}
@Override
public String getURLSuffix() {
return "/contributors?per_page=100&page=" + page;
public String getEndpoint() {
return "/contributors";
}
@Override
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<>();
parameters.put("per_page", 100);
parameters.put("page", page);
return parameters;
}
private void computeContributors(@Nonnull JSONArray array) {

View File

@ -1,6 +1,8 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
@ -35,8 +37,13 @@ class GitHubActivityConnector extends GitHubConnector {
}
@Override
public String getURLSuffix() {
public String getEndpoint() {
return "";
}
@Override
public Map<String, Object> getParameters() {
return new HashMap<>();
}
}

View File

@ -6,12 +6,13 @@ import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import kong.unirest.HttpResponse;
import kong.unirest.JsonNode;
@ -31,22 +32,49 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
abstract class GitHubConnector {
private static final String API_URL = "https://api.github.com/";
private static final String USER_AGENT = "Slimefun4 (https://github.com/Slimefun)";
protected File file;
protected String repository;
protected final GitHubService github;
private final String url;
private File file;
@ParametersAreNonnullByDefault
public GitHubConnector(GitHubService github, String repository) {
/**
* This creates a new {@link GitHubConnector} for the given repository.
*
* @param github
* Our instance of {@link GitHubService}
* @param repository
* The repository we want to connect to
*/
GitHubConnector(@Nonnull GitHubService github, @Nonnull String repository) {
this.github = github;
this.repository = repository;
this.url = API_URL + "repos/" + repository + getEndpoint();
}
/**
* This returns the name of our cache {@link File}.
*
* @return The cache {@link File} name
*/
@Nonnull
public abstract String getFileName();
/**
* This is our {@link URL} endpoint.
* It is the suffix of the {@link URL} we want to connect to.
*
* @return Our endpoint
*/
@Nonnull
public abstract String getURLSuffix();
public abstract String getEndpoint();
/**
* This {@link Map} contains the query parameters for our {@link URL}.
*
* @return A {@link Map} with our query parameters
*/
@Nonnull
public abstract Map<String, Object> getParameters();
/**
* This method is called when the connection finished successfully.
@ -63,7 +91,12 @@ abstract class GitHubConnector {
// Don't do anything by default
}
public void pullFile() {
/**
* This method will connect to GitHub and store the received data inside a local
* cache {@link File}.
* Make sure to call this method asynchronously!
*/
void download() {
file = new File("plugins/Slimefun/cache/github/" + getFileName() + ".json");
if (github.isLoggingEnabled()) {
@ -71,16 +104,19 @@ abstract class GitHubConnector {
}
try {
HttpResponse<JsonNode> resp = Unirest.get(API_URL + "repos/" + repository + getURLSuffix())
.header("User-Agent", "Slimefun4 (https://github.com/Slimefun)")
// @formatter:off
HttpResponse<JsonNode> response = Unirest.get(url)
.queryString(getParameters())
.header("User-Agent", USER_AGENT)
.asJson();
// @formatter:on
if (resp.isSuccess()) {
onSuccess(resp.getBody());
writeCacheFile(resp.getBody());
if (response.isSuccess()) {
onSuccess(response.getBody());
writeCacheFile(response.getBody());
} else {
if (github.isLoggingEnabled()) {
Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { repository + getURLSuffix(), resp.getStatus(), resp.getBody() });
Slimefun.getLogger().log(Level.WARNING, "Failed to fetch {0}: {1} - {2}", new Object[] { url, response.getStatus(), response.getBody() });
}
// It has the cached file, let's just read that then

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import javax.annotation.Nonnull;
@ -50,8 +52,15 @@ class GitHubIssuesConnector extends GitHubConnector {
}
@Override
public String getURLSuffix() {
return "/issues?per_page=100";
public String getEndpoint() {
return "/issues";
}
@Override
public Map<String, Object> getParameters() {
Map<String, Object> parameters = new HashMap<>();
parameters.put("per_page", 100);
return parameters;
}
}

View File

@ -57,7 +57,8 @@ public class GitHubService {
}
public void start(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, new GitHubTask(this), 80L, 60 * 60 * 20L);
GitHubTask task = new GitHubTask(this);
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, task, 80L, 60 * 60 * 20L);
}
/**

View File

@ -1,5 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@ -38,10 +39,14 @@ class GitHubTask implements Runnable {
@Override
public void run() {
gitHubService.getConnectors().forEach(GitHubConnector::pullFile);
gitHubService.getConnectors().forEach(GitHubConnector::download);
grabTextures();
}
/**
* This method will pull the skin textures for every {@link Contributor} and store
* the {@link UUID} and received skin inside a local cache {@link File}.
*/
private void grabTextures() {
// Store all queried usernames to prevent 429 responses for pinging the
// same URL twice in one run.

View File

@ -11,11 +11,19 @@ import org.bukkit.event.Listener;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.minebuilders.clearlag.Clearlag;
import me.minebuilders.clearlag.events.EntityRemoveEvent;
class ClearLagHook implements Listener {
/**
* This handles all integrations with {@link Clearlag}.
* We don't want it to clear our altar items.
*
* @author TheBusyBiscuit
*
*/
class ClearLagIntegration implements Listener {
ClearLagHook(@Nonnull SlimefunPlugin plugin) {
ClearLagIntegration(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}

View File

@ -12,6 +12,7 @@ import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuideLayout;
import me.mrCookieSlime.EmeraldEnchants.EnchantmentGuide;
@Deprecated
class EmeraldEnchantsCategory extends FlexCategory {
public EmeraldEnchantsCategory(@Nonnull NamespacedKey key) {

View File

@ -0,0 +1,60 @@
package io.github.thebusybiscuit.slimefun4.core.services.plugins;
import javax.annotation.Nonnull;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.events.skills.salvage.McMMOPlayerSalvageCheckEvent;
import io.github.thebusybiscuit.slimefun4.api.events.BlockPlacerPlaceEvent;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This handles all integrations with {@link mcMMO}.
*
* @author TheBusyBiscuit
*
*/
class McMMOIntegration implements Listener {
McMMOIntegration(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlacerPlace(BlockPlacerPlaceEvent e) {
// This registers blocks placed by the BlockPlacer as "player-placed"
mcMMO.getPlaceStore().setTrue(e.getBlock());
}
@EventHandler(ignoreCancelled = true)
public void onItemSalvage(McMMOPlayerSalvageCheckEvent e) {
// Prevent Slimefun items from being salvaged
if (!isSalvageable(e.getSalvageItem())) {
e.setCancelled(true);
SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "anvil.mcmmo-salvaging");
}
}
/**
* This method checks if an {@link ItemStack} can be salvaged or not.
* We basically don't want players to salvage any {@link SlimefunItem} unless
* it is a {@link VanillaItem}.
*
* @param item
* The {@link ItemStack} to check
*
* @return Whether this item can be safely salvaged
*/
private boolean isSalvageable(@Nonnull ItemStack item) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
return sfItem == null || sfItem instanceof VanillaItem;
}
}

View File

@ -13,14 +13,21 @@ import org.bukkit.entity.Player;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.researching.Research;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.clip.placeholderapi.PlaceholderAPI;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
class PlaceholderAPIHook extends PlaceholderExpansion {
/**
* This is our integration for {@link PlaceholderAPI}.
*
* @author TheBusyBiscuit
*
*/
class PlaceholderAPIIntegration extends PlaceholderExpansion {
private final String version;
private final String author;
public PlaceholderAPIHook(@Nonnull SlimefunPlugin plugin) {
public PlaceholderAPIIntegration(@Nonnull SlimefunPlugin plugin) {
this.version = plugin.getDescription().getVersion();
this.author = plugin.getDescription().getAuthors().toString();
}

View File

@ -5,12 +5,16 @@ import java.util.function.Function;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@ -31,25 +35,41 @@ public class ThirdPartyPluginService {
private final SlimefunPlugin plugin;
private boolean initialized = false;
private boolean isExoticGardenInstalled = false;
private boolean isChestTerminalInstalled = false;
private boolean isEmeraldEnchantsInstalled = false;
private boolean isCoreProtectInstalled = false;
private boolean isPlaceholderAPIInstalled = false;
private boolean isMcMMOInstalled = false;
// Overridden if ExoticGarden is loaded
/**
* This gets overridden if ExoticGarden is loaded
*/
private Function<Block, Optional<ItemStack>> exoticGardenIntegration = b -> Optional.empty();
/**
* This initializes the {@link ThirdPartyPluginService}
*
* @param plugin
* Our instance of {@link SlimefunPlugin}
*/
public ThirdPartyPluginService(@Nonnull SlimefunPlugin plugin) {
this.plugin = plugin;
}
/**
* This method initializes all third party integrations.
*/
public void start() {
if (initialized) {
throw new UnsupportedOperationException("Third Party Integrations have already been initialized!");
}
initialized = true;
if (isPluginInstalled("PlaceholderAPI")) {
try {
PlaceholderAPIHook hook = new PlaceholderAPIHook(plugin);
PlaceholderAPIIntegration hook = new PlaceholderAPIIntegration(plugin);
hook.register();
isPlaceholderAPIInstalled = true;
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("PlaceholderAPI").getDescription().getVersion();
@ -69,7 +89,7 @@ public class ThirdPartyPluginService {
if (isPluginInstalled("WorldEdit")) {
try {
Class.forName("com.sk89q.worldedit.extent.Extent");
new WorldEditHook();
new WorldEditIntegration();
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("WorldEdit").getDescription().getVersion();
@ -78,6 +98,21 @@ public class ThirdPartyPluginService {
}
}
// mcMMO Integration
if (isPluginInstalled("mcMMO")) {
try {
// This makes sure that the FakeEvent interface is present.
// Class.forName("com.gmail.nossr50.events.fake.FakeEvent");
new McMMOIntegration(plugin);
isMcMMOInstalled = true;
} catch (Exception | LinkageError x) {
String version = plugin.getServer().getPluginManager().getPlugin("mcMMO").getDescription().getVersion();
Slimefun.getLogger().log(Level.WARNING, "Maybe consider updating mcMMO or Slimefun?");
Slimefun.getLogger().log(Level.WARNING, x, () -> "Failed to hook into mcMMO v" + version);
}
}
/*
* These Items are not marked as soft-dependencies and
* therefore need to be loaded after the Server has finished
@ -85,7 +120,7 @@ public class ThirdPartyPluginService {
*/
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
if (isPluginInstalled("ClearLag")) {
new ClearLagHook(plugin);
new ClearLagIntegration(plugin);
}
isChestTerminalInstalled = isPluginInstalled("ChestTerminal");
@ -101,6 +136,7 @@ public class ThirdPartyPluginService {
}
}
@ParametersAreNonnullByDefault
public void loadExoticGarden(Plugin plugin, Function<Block, Optional<ItemStack>> method) {
if (plugin.getName().equals("ExoticGarden")) {
isExoticGardenInstalled = true;
@ -120,16 +156,22 @@ public class ThirdPartyPluginService {
return isEmeraldEnchantsInstalled;
}
public boolean isCoreProtectInstalled() {
return isCoreProtectInstalled;
}
public boolean isPlaceholderAPIInstalled() {
return isPlaceholderAPIInstalled;
}
public Optional<ItemStack> harvestExoticGardenPlant(Block block) {
return exoticGardenIntegration.apply(block);
}
/**
* This checks if one of our third party integrations faked an {@link Event}.
* Faked {@link Event Events} should be ignored in our logic.
*
* @param event
* The {@link Event} to test
*
* @return Whether this is a fake event
*/
public boolean isEventFaked(@Nonnull Event event) {
// TODO: Change this to FakeEvent once the new mcMMO build was released
return isMcMMOInstalled && event instanceof FakeBlockBreakEvent;
}
}

View File

@ -14,9 +14,16 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
class WorldEditHook {
/**
* This handles all integrations with {@link WorldEdit}.
* If an are is cleared, we also wanna clear all Slimefun-related block data.
*
* @author TheBusyBiscuit
*
*/
class WorldEditIntegration {
WorldEditHook() {
WorldEditIntegration() {
WorldEdit.getInstance().getEventBus().register(this);
}

View File

@ -394,7 +394,7 @@ public final class SlimefunItems {
public static final SlimefunItemStack PLASTIC_SHEET = new SlimefunItemStack("PLASTIC_SHEET", Material.PAPER, "&fPlastic Sheet");
public static final SlimefunItemStack MAGNET = new SlimefunItemStack("MAGNET", HeadTexture.MAGNET, "&cMagnet");
public static final SlimefunItemStack NECROTIC_SKULL = new SlimefunItemStack("NECROTIC_SKULL", Material.WITHER_SKELETON_SKULL, "&cNecrotic Skull");
public static final SlimefunItemStack NECROTIC_SKULL = new SlimefunItemStack("NECROTIC_SKULL", HeadTexture.NECROTIC_SKULL, "&cNecrotic Skull");
public static final SlimefunItemStack ESSENCE_OF_AFTERLIFE = new SlimefunItemStack("ESSENCE_OF_AFTERLIFE", Material.GUNPOWDER, "&4Essence of Afterlife");
public static final SlimefunItemStack STRANGE_NETHER_GOO = new SlimefunItemStack("STRANGE_NETHER_GOO", Material.PURPLE_DYE, "&5Strange Nether Goo", "", "&fA strange bio matter that", "&fcan be acquired from", "&fbartering with Piglins");
public static final SlimefunItemStack ELECTRO_MAGNET = new SlimefunItemStack("ELECTRO_MAGNET", HeadTexture.MAGNET, "&cElectromagnet");
@ -569,14 +569,14 @@ public final class SlimefunItems {
public static final SlimefunItemStack ENHANCED_CRAFTING_TABLE = new SlimefunItemStack("ENHANCED_CRAFTING_TABLE", Material.CRAFTING_TABLE, "&eEnhanced Crafting Table", "", "&aA regular Crafting Table cannot", "&ahold this massive Amount of Power...");
public static final SlimefunItemStack GRIND_STONE = new SlimefunItemStack("GRIND_STONE", Material.DISPENSER, "&bGrind Stone", "", "&aGrinds items down into other items");
public static final SlimefunItemStack ARMOR_FORGE = new SlimefunItemStack("ARMOR_FORGE", Material.ANVIL, "&6Armor Forge", "", "&aGives you the ability to create powerful armor");
public static final SlimefunItemStack MAKESHIFT_SMELTERY;
public static final SlimefunItemStack MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.BLAST_FURNACE, "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots");
public static final SlimefunItemStack SMELTERY = new SlimefunItemStack("SMELTERY", Material.FURNACE, "&6Smeltery", "", "&fA high-temperature furnace", "&fthat allows you to smelt dusts", "&finto ingots and create alloys.");
public static final SlimefunItemStack ORE_CRUSHER = new SlimefunItemStack("ORE_CRUSHER", Material.DISPENSER, "&bOre Crusher", "", "&aCrushes ores to double them");
public static final SlimefunItemStack COMPRESSOR = new SlimefunItemStack("COMPRESSOR", Material.PISTON, "&bCompressor", "", "&aCompresses Items");
public static final SlimefunItemStack PRESSURE_CHAMBER = new SlimefunItemStack("PRESSURE_CHAMBER", Material.GLASS, "&bPressure Chamber", "", "&aCompresses Items even further");
public static final SlimefunItemStack MAGIC_WORKBENCH = new SlimefunItemStack("MAGIC_WORKBENCH", Material.CRAFTING_TABLE, "&6Magic Workbench", "", "&dInfuses Items with magical Energy");
public static final SlimefunItemStack ORE_WASHER = new SlimefunItemStack("ORE_WASHER", Material.CAULDRON, "&6Ore Washer", "", "&aWashes Sifted Ore to filter Ores", "&aand gives you small Stone Chunks");
public static final SlimefunItemStack TABLE_SAW;
public static final SlimefunItemStack TABLE_SAW = new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6Table Saw", "", "&aAllows you to get 8 planks from 1 Log", "&a(Works with all log types)");
public static final SlimefunItemStack JUICER = new SlimefunItemStack("JUICER", Material.GLASS_BOTTLE, "&aJuicer", "", "&aAllows you to create delicious Juice");
public static final SlimefunItemStack AUTOMATED_PANNING_MACHINE = new SlimefunItemStack("AUTOMATED_PANNING_MACHINE", Material.BOWL, "&eAutomated Panning Machine", "", "&fA MultiBlock Version of the Gold Pan", "&fand Nether Gold Pan combined in one machine.");
@ -664,12 +664,12 @@ public final class SlimefunItems {
public static final SlimefunItemStack ELECTRIC_ORE_GRINDER = new SlimefunItemStack("ELECTRIC_ORE_GRINDER", Material.FURNACE, "&cElectric Ore Grinder", "", "&fWorks as an Ore Crusher and Grind Stone", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12));
public static final SlimefunItemStack ELECTRIC_ORE_GRINDER_2 = new SlimefunItemStack("ELECTRIC_ORE_GRINDER_2", Material.FURNACE, "&cElectric Ore Grinder &7(&eII&7)", "", "&fWorks as an Ore Crusher and Grind Stone", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), LoreBuilder.speed(4), LoreBuilder.powerPerSecond(30));
public static final SlimefunItemStack ELECTRIC_INGOT_PULVERIZER = new SlimefunItemStack("ELECTRIC_INGOT_PULVERIZER", Material.FURNACE, "&cElectric Ingot Pulverizer", "", "&fPulverizes Ingots into Dust", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(14));
public static final SlimefunItemStack AUTO_DRIER;
public static final SlimefunItemStack AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.SMOKER, "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10));
public static final SlimefunItemStack AUTO_ENCHANTER = new SlimefunItemStack("AUTO_ENCHANTER", Material.ENCHANTING_TABLE, "&5Auto Enchanter", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18));
public static final SlimefunItemStack AUTO_DISENCHANTER = new SlimefunItemStack("AUTO_DISENCHANTER", Material.ENCHANTING_TABLE, "&5Auto Disenchanter", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(18));
public static final SlimefunItemStack AUTO_ANVIL = new SlimefunItemStack("AUTO_ANVIL", Material.IRON_BLOCK, "&7Auto Anvil", "", LoreBuilder.machine(MachineTier.ADVANCED, MachineType.MACHINE), "&8\u21E8 &7Repair Factor: 10%", LoreBuilder.powerPerSecond(24));
public static final SlimefunItemStack AUTO_ANVIL_2 = new SlimefunItemStack("AUTO_ANVIL_2", Material.IRON_BLOCK, "&7Auto Anvil Mk.II", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.MACHINE), "&8\u21E8 &7Repair Factor: 25%", LoreBuilder.powerPerSecond(32));
public static final SlimefunItemStack AUTO_BREWER;
public static final SlimefunItemStack AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", Material.SMOKER, "&6Auto Brewer", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12));
public static final SlimefunItemStack BIO_REACTOR = new SlimefunItemStack("BIO_REACTOR", Material.LIME_TERRACOTTA, "&2Bio Reactor", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.GENERATOR), LoreBuilder.powerBuffer(128), LoreBuilder.powerPerSecond(8));
public static final SlimefunItemStack MULTIMETER = new SlimefunItemStack("MULTIMETER", Material.CLOCK, "&eMultimeter", "", "&fMeasures the Amount of stored", "&fEnergy in a Block");
@ -843,17 +843,5 @@ public final class SlimefunItems {
static {
INFUSED_ELYTRA.addUnsafeEnchantment(Enchantment.MENDING, 1);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
TABLE_SAW = new SlimefunItemStack("TABLE_SAW", Material.STONECUTTER, "&6Table Saw", "", "&aAllows you to get 8 planks from 1 Log", "&a(Works with all log types)");
MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.BLAST_FURNACE, "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots");
AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.SMOKER, "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10));
AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", Material.SMOKER, "&6Auto Brewer", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12));
} else {
TABLE_SAW = null;
MAKESHIFT_SMELTERY = new SlimefunItemStack("MAKESHIFT_SMELTERY", Material.FURNACE, "&eMakeshift Smeltery", "", "&fImprovised version of the Smeltery", "&fthat only allows you to", "&fsmelt dusts into ingots");
AUTO_DRIER = new SlimefunItemStack("AUTO_DRIER", Material.FURNACE, "&6Auto Drier", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(10));
AUTO_BREWER = new SlimefunItemStack("AUTO_BREWER", Material.BREWING_STAND, "&6Auto Brewer", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.MACHINE), LoreBuilder.speed(1), LoreBuilder.powerPerSecond(12));
}
}
}

View File

@ -89,10 +89,15 @@ import io.github.thebusybiscuit.slimefun4.implementation.listeners.SlimefunItemL
import io.github.thebusybiscuit.slimefun4.implementation.listeners.SoulboundListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.TalismanListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VampireBladeListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VanillaMachinesListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.VillagerTradingListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WitherListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.WorldListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.AnvilListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.BrewingStandListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CartographyTableListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CauldronListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.CraftingTableListener;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.GrindstoneListener;
import io.github.thebusybiscuit.slimefun4.implementation.resources.GEOResourcesSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.PostSetup;
import io.github.thebusybiscuit.slimefun4.implementation.setup.ResearchSetup;
@ -176,9 +181,14 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
command.register();
registry.load(config);
} else if (getServer().getPluginManager().isPluginEnabled("CS-CoreLib")) {
getLogger().log(Level.INFO, "CS-CoreLib was detected!");
long timestamp = System.nanoTime();
PaperLib.suggestPaper(this);
if (PaperLib.isPaper()) {
getLogger().log(Level.INFO, "Paper was detected! Performance optimizations have been applied.");
}
// We wanna ensure that the Server uses a compatible version of Minecraft
if (isVersionUnsupported()) {
getServer().getPluginManager().disablePlugin(this);
@ -270,7 +280,10 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
autoSavingService.start(this, config.getInt("options.auto-save-delay-in-minutes"));
ticker.start(this);
getLogger().log(Level.INFO, "Loading Third-Party plugin integrations...");
thirdPartySupportService.start();
gitHubService.start(this);
// Hooray!
@ -445,7 +458,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new DeathpointListener(this);
new ExplosionsListener(this);
new DebugFishListener(this);
new VanillaMachinesListener(this);
new FireworksListener(this);
new WitherListener(this);
new IronGolemListener(this);
@ -453,6 +465,12 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new MobDropListener(this);
new VillagerTradingListener(this);
new ElytraCrashListener(this);
new CraftingTableListener(this);
new AnvilListener(this);
new BrewingStandListener(this);
new CauldronListener(this);
new GrindstoneListener(this);
new CartographyTableListener(this);
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
new BeeListener(this);
@ -469,6 +487,7 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new AncientAltarListener(this, (AncientAltar) SlimefunItems.ANCIENT_ALTAR.getItem(), (AncientPedestal) SlimefunItems.ANCIENT_PEDESTAL.getItem());
grapplingHookListener.register(this, (GrapplingHook) SlimefunItems.GRAPPLING_HOOK.getItem());
bowListener.register(this);
backpackListener.register(this);
// Toggleable Listeners for performance reasons
if (config.getBoolean("items.talismans")) {
@ -479,10 +498,6 @@ public final class SlimefunPlugin extends JavaPlugin implements SlimefunAddon {
new SoulboundListener(this);
}
if (config.getBoolean("items.backpacks")) {
backpackListener.register(this);
}
// Handle Slimefun Guide being given on Join
new SlimefunGuideListener(this, config.getBoolean("guide.receive-on-first-join"));

View File

@ -1,7 +1,5 @@
package io.github.thebusybiscuit.slimefun4.implementation.guide;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
@ -10,6 +8,9 @@ import java.util.Locale;
import java.util.Optional;
import java.util.logging.Level;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -26,7 +27,6 @@ import io.github.thebusybiscuit.cscorelib2.chat.ChatInput;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.cscorelib2.recipes.MinecraftRecipe;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.categories.FlexCategory;
@ -65,21 +65,15 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
public class ChestSlimefunGuide implements SlimefunGuideImplementation {
private static final int CATEGORY_SIZE = 36;
private static final Sound sound = Sound.ITEM_BOOK_PAGE_TURN;
private final ItemStack item;
private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 };
private final Sound sound;
private final ItemStack item;
private final boolean showVanillaRecipes;
public ChestSlimefunGuide(boolean vanillaRecipes) {
showVanillaRecipes = vanillaRecipes;
public ChestSlimefunGuide(boolean showVanillaRecipes) {
this.showVanillaRecipes = showVanillaRecipes;
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
sound = Sound.ITEM_BOOK_PAGE_TURN;
} else {
sound = Sound.ENTITY_BAT_TAKEOFF;
}
}
@Override
@ -132,7 +126,6 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
}
ChestMenu menu = create(p);
List<Category> categories = getVisibleCategories(p, profile);
int index = 9;
@ -278,10 +271,10 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
if (isSurvivalMode() && !Slimefun.hasPermission(p, sfitem, false)) {
List<String> message = SlimefunPlugin.getPermissionsService().getLore(sfitem);
menu.addItem(index, new CustomItem(Material.BARRIER, sfitem.getItemName(), message.toArray(new String[0])));
menu.addItem(index, new CustomItem(ChestMenuUtils.getNoPermissionItem(), sfitem.getItemName(), message.toArray(new String[0])));
menu.addMenuClickHandler(index, ChestMenuUtils.getEmptyClickHandler());
} else if (isSurvivalMode() && research != null && !profile.hasUnlocked(research)) {
menu.addItem(index, new CustomItem(Material.BARRIER, ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
menu.addItem(index, new CustomItem(ChestMenuUtils.getNotResearchedItem(), ChatColor.WHITE + ItemUtils.getItemName(sfitem.getItem()), "&4&l" + SlimefunPlugin.getLocalization().getMessage(p, "guide.locked"), "", "&a> Click to unlock", "", "&7Cost: &b" + research.getCost() + " Level(s)"));
menu.addMenuClickHandler(index, (pl, slot, item, action) -> {
if (!SlimefunPlugin.getRegistry().getCurrentlyResearchingPlayers().contains(pl.getUniqueId())) {
if (research.canUnlock(pl)) {
@ -341,26 +334,14 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
int index = 9;
// Find items and add them
for (SlimefunItem slimefunItem : SlimefunPlugin.getRegistry().getEnabledSlimefunItems()) {
String itemName = ChatColor.stripColor(slimefunItem.getItemName()).toLowerCase(Locale.ROOT);
if (index == 44) {
break;
}
if (!itemName.isEmpty() && (itemName.equals(searchTerm) || itemName.contains(searchTerm))) {
if (isSearchFilterApplicable(slimefunItem, searchTerm)) {
ItemStack itemstack = new CustomItem(slimefunItem.getItem(), meta -> {
List<String> lore = null;
Category category = slimefunItem.getCategory();
if (category != null) {
ItemStack categoryItem = category.getItem(p);
if (categoryItem != null && categoryItem.hasItemMeta() && categoryItem.getItemMeta().hasDisplayName()) {
lore = Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + categoryItem.getItemMeta().getDisplayName());
}
}
meta.setLore(lore);
meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + category.getDisplayName(p)));
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES, ItemFlag.HIDE_ENCHANTS, ItemFlag.HIDE_POTION_EFFECTS);
});
@ -386,6 +367,12 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
menu.open(p);
}
@ParametersAreNonnullByDefault
private boolean isSearchFilterApplicable(SlimefunItem slimefunItem, String searchTerm) {
String itemName = ChatColor.stripColor(slimefunItem.getItemName()).toLowerCase(Locale.ROOT);
return !itemName.isEmpty() && (itemName.equals(searchTerm) || itemName.contains(searchTerm));
}
@Override
public void displayItem(PlayerProfile profile, ItemStack item, int index, boolean addToHistory) {
Player p = profile.getPlayer();

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
import javax.annotation.Nonnull;
/**
* This enum holds all the different types a {@link ProgrammableAndroid} can represent.
*
@ -55,7 +57,7 @@ public enum AndroidType {
*/
NON_FIGHTER;
boolean isType(AndroidType type) {
boolean isType(@Nonnull AndroidType type) {
return type == NONE || type == this || (type == NON_FIGHTER && this != FIGHTER);
}

View File

@ -10,8 +10,6 @@ import org.bukkit.block.data.Ageable;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@ -57,10 +55,6 @@ public class FarmerAndroid extends ProgrammableAndroid {
private ItemStack getDropFromCrop(Material crop) {
Random random = ThreadLocalRandom.current();
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) && crop == Material.SWEET_BERRY_BUSH) {
return new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1);
}
switch (crop) {
case WHEAT:
return new ItemStack(Material.WHEAT, random.nextInt(2) + 1);
@ -74,6 +68,8 @@ public class FarmerAndroid extends ProgrammableAndroid {
return new ItemStack(Material.COCOA_BEANS, random.nextInt(3) + 1);
case NETHER_WART:
return new ItemStack(Material.NETHER_WART, random.nextInt(3) + 1);
case SWEET_BERRY_BUSH:
return new ItemStack(Material.SWEET_BERRIES, random.nextInt(3) + 1);
default:
return null;
}

View File

@ -10,8 +10,6 @@ import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.collections.RandomizedSet;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
@ -37,10 +35,7 @@ public class FisherAndroid extends ProgrammableAndroid {
fishingLoot.add(new ItemStack(Material.STICK), 5);
fishingLoot.add(new ItemStack(Material.ROTTEN_FLESH), 3);
fishingLoot.add(new ItemStack(Material.LEATHER), 2);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
fishingLoot.add(new ItemStack(Material.BAMBOO), 3);
}
// "loot"
fishingLoot.add(new ItemStack(Material.SADDLE), 1);

View File

@ -8,6 +8,7 @@ import java.util.Map;
import java.util.function.Predicate;
import org.apache.commons.lang.Validate;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Ageable;
@ -20,126 +21,223 @@ import io.github.thebusybiscuit.slimefun4.utils.HeadTexture;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
enum Instruction {
/**
* This enum holds every {@link Instruction} for the {@link ProgrammableAndroid}
* added by Slimefun itself.
*
* @author TheBusyBiscuit
*
*/
public enum Instruction {
// Start and End Parts
/**
* This {@link Instruction} is the starting point of a {@link Script}.
*/
START(AndroidType.NONE, HeadTexture.SCRIPT_START),
/**
* This {@link Instruction} is the end token of a {@link Script}.
* Once this {@link Instruction} is reached, the {@link Script} will start again.
*/
REPEAT(AndroidType.NONE, HeadTexture.SCRIPT_REPEAT),
/**
* This {@link Instruction} will make the {@link ProgrammableAndroid} wait
* for one Slimefun tick.
*/
WAIT(AndroidType.NONE, HeadTexture.SCRIPT_WAIT),
// Movement
/**
* This will make the {@link ProgrammableAndroid} go forward.
*/
GO_FORWARD(AndroidType.NON_FIGHTER, HeadTexture.SCRIPT_FORWARD, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.move(b, face, target);
}),
/**
* This will make the {@link ProgrammableAndroid} go up.
*/
GO_UP(AndroidType.NON_FIGHTER, HeadTexture.SCRIPT_UP, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.UP);
android.move(b, face, target);
}),
/**
* This will make the {@link ProgrammableAndroid} go down.
*/
GO_DOWN(AndroidType.NON_FIGHTER, HeadTexture.SCRIPT_DOWN, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.DOWN);
android.move(b, face, target);
}),
// Directions
/**
* This will make the {@link ProgrammableAndroid} rotate to the left side.
*/
TURN_LEFT(AndroidType.NONE, HeadTexture.SCRIPT_LEFT, (android, b, inv, face) -> {
int mod = -1;
android.rotate(b, face, mod);
}),
/**
* This will make the {@link ProgrammableAndroid} rotate to the right side.
*/
TURN_RIGHT(AndroidType.NONE, HeadTexture.SCRIPT_RIGHT, (android, b, inv, face) -> {
int mod = 1;
android.rotate(b, face, mod);
}),
// Action - Pickaxe
/**
* This will make a {@link MinerAndroid} dig the {@link Block} above.
*/
DIG_UP(AndroidType.MINER, HeadTexture.SCRIPT_DIG_UP, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.UP);
android.dig(b, inv, target);
}),
/**
* This will make a {@link MinerAndroid} dig the {@link Block} ahead.
*/
DIG_FORWARD(AndroidType.MINER, HeadTexture.SCRIPT_DIG_FORWARD, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.dig(b, inv, target);
}),
/**
* This will make a {@link MinerAndroid} dig the {@link Block} below.
*/
DIG_DOWN(AndroidType.MINER, HeadTexture.SCRIPT_DIG_DOWN, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.DOWN);
android.dig(b, inv, target);
}),
/**
* This will make a {@link MinerAndroid} dig the {@link Block} above
* and then move itself to that new {@link Location}.
*/
MOVE_AND_DIG_UP(AndroidType.MINER, HeadTexture.SCRIPT_DIG_UP, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.UP);
android.moveAndDig(b, inv, face, target);
}),
/**
* This will make a {@link MinerAndroid} dig the {@link Block} ahead
* and then move itself to that new {@link Location}.
*/
MOVE_AND_DIG_FORWARD(AndroidType.MINER, HeadTexture.SCRIPT_DIG_FORWARD, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.moveAndDig(b, inv, face, target);
}),
/**
* This will make a {@link MinerAndroid} dig the {@link Block} below
* and then move itself to that new {@link Location}.
*/
MOVE_AND_DIG_DOWN(AndroidType.MINER, HeadTexture.SCRIPT_DIG_DOWN, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.DOWN);
android.moveAndDig(b, inv, face, target);
}),
// Action - Sword
/**
* This will make a {@link ButcherAndroid} attack any {@link LivingEntity}
* ahead of them.
*/
ATTACK_MOBS_ANIMALS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate<LivingEntity> predicate = e -> true;
android.attack(b, face, predicate);
}),
/**
* This will make a {@link ButcherAndroid} attack any {@link Monster}
* ahead of them.
*/
ATTACK_MOBS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate<LivingEntity> predicate = e -> e instanceof Monster;
android.attack(b, face, predicate);
}),
/**
* This will make a {@link ButcherAndroid} attack any {@link Animals Animal}
* ahead of them.
*/
ATTACK_ANIMALS(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate<LivingEntity> predicate = e -> e instanceof Animals;
android.attack(b, face, predicate);
}),
/**
* This will make a {@link ButcherAndroid} attack any <strong>adult</strong>
* {@link Animals Animal} ahead of them.
*/
ATTACK_ANIMALS_ADULT(AndroidType.FIGHTER, HeadTexture.SCRIPT_ATTACK, (android, b, inv, face) -> {
Predicate<LivingEntity> predicate = e -> e instanceof Animals && e instanceof Ageable && ((Ageable) e).isAdult();
Predicate<LivingEntity> predicate = e -> e instanceof Animals && ((Ageable) e).isAdult();
android.attack(b, face, predicate);
}),
// Action - Axe
/**
* This will make a {@link WoodcutterAndroid} chop down the tree in front of them.
*/
CHOP_TREE(AndroidType.WOODCUTTER, HeadTexture.SCRIPT_CHOP_TREE),
// Action - Fishing Rod
/**
* This {@link Instruction} makes a {@link FisherAndroid} try to catch fish from
* the water below.
*/
CATCH_FISH(AndroidType.FISHERMAN, HeadTexture.SCRIPT_FISH, (android, b, inv, face) -> android.fish(b, inv)),
// Action - Hoe
/**
* This {@link Instruction} will make a {@link FarmerAndroid} try to harvest
* the {@link Block} in front of them.
*/
FARM_FORWARD(AndroidType.FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.farm(inv, target);
}),
/**
* This {@link Instruction} will make a {@link FarmerAndroid} try to harvest
* the {@link Block} below.
*/
FARM_DOWN(AndroidType.FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.DOWN);
android.farm(inv, target);
}),
// Action - ExoticGarden
/**
* This {@link Instruction} will make a {@link FarmerAndroid} try to harvest
* the {@link Block} in front of them.
*
* <strong>This includes plants from ExoticGarden.</strong>
*/
FARM_EXOTIC_FORWARD(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_FORWARD, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.exoticFarm(inv, target);
}),
/**
* This {@link Instruction} will make a {@link FarmerAndroid} try to harvest
* the {@link Block} below.
*
* <strong>This includes plants from ExoticGarden.</strong>
*/
FARM_EXOTIC_DOWN(AndroidType.ADVANCED_FARMER, HeadTexture.SCRIPT_FARM_DOWN, (android, b, inv, face) -> {
Block target = b.getRelative(BlockFace.DOWN);
android.exoticFarm(inv, target);
}),
// Action - Interface
/**
* This {@link Instruction} will force the {@link ProgrammableAndroid} to push their
* items into an {@link AndroidInterface} ahead of them.
*/
INTERFACE_ITEMS(AndroidType.NONE, HeadTexture.SCRIPT_PUSH_ITEMS, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.depositItems(inv, target);
}),
/**
* This {@link Instruction} will force the {@link ProgrammableAndroid} to pull
* fuel from an {@link AndroidInterface} ahead of them.
*/
INTERFACE_FUEL(AndroidType.NONE, HeadTexture.SCRIPT_PULL_FUEL, (android, b, inv, face) -> {
Block target = b.getRelative(face);
android.refuel(inv, target);

View File

@ -58,6 +58,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.interfaces.InventoryBlock;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset;
@ -69,6 +70,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
private static final int[] BORDER = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 24, 25, 26, 27, 33, 35, 36, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 };
private static final int[] OUTPUT_BORDER = { 10, 11, 12, 13, 14, 19, 23, 28, 32, 37, 38, 39, 40, 41 };
private static final String DEFAULT_SCRIPT = "START-TURN_LEFT-REPEAT";
private static final int MAX_SCRIPT_LENGTH = 54;
protected final List<MachineFuel> fuelTypes = new ArrayList<>();
protected final String texture;
@ -407,6 +409,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
} else {
Script script = scripts.get(target);
menu.addItem(index, script.getAsItemStack(this, p), (player, slot, stack, action) -> {
try {
if (action.isShiftClicked()) {
if (script.isAuthor(player)) {
SlimefunPlugin.getLocalization().sendMessage(player, "android.scripts.rating.own", true);
@ -421,6 +424,9 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
setScript(b.getLocation(), script.getSourceCode());
openScriptEditor(player, b);
}
} catch (Exception x) {
Slimefun.getLogger().log(Level.SEVERE, "An Exception was thrown when a User tried to download a Script!", x);
}
return false;
});
@ -534,12 +540,19 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
}
@Nonnull
protected String getScript(@Nonnull Location l) {
public String getScript(@Nonnull Location l) {
Validate.notNull(l, "Location for android not specified");
String script = BlockStorage.getLocationInfo(l, "script");
return script != null ? script : DEFAULT_SCRIPT;
}
protected void setScript(@Nonnull Location l, @Nonnull String script) {
public void setScript(@Nonnull Location l, @Nonnull String script) {
Validate.notNull(l, "Location for android not specified");
Validate.notNull(script, "No script given");
Validate.isTrue(script.startsWith(Instruction.START.name() + '-'), "A script must begin with a 'START' token.");
Validate.isTrue(script.endsWith('-' + Instruction.REPEAT.name()), "A script must end with a 'REPEAT' token.");
Validate.isTrue(PatternUtils.DASH.split(script).length <= MAX_SCRIPT_LENGTH, "Scripts may not have more than " + MAX_SCRIPT_LENGTH + " segments");
BlockStorage.addBlockInfo(l, "script", script);
}

View File

@ -130,18 +130,19 @@ public final class Script {
@Nonnull
ItemStack getAsItemStack(@Nonnull ProgrammableAndroid android, @Nonnull Player p) {
List<String> lore = new LinkedList<>();
lore.add("&7by &r" + getAuthor());
lore.add("&7by &f" + getAuthor());
lore.add("");
lore.add("&7Downloads: &r" + getDownloads());
lore.add("&7Downloads: &f" + getDownloads());
lore.add("&7Rating: " + getScriptRatingPercentage());
lore.add("&a" + getUpvotes() + " \u263A &7| &4\u2639 " + getDownvotes());
lore.add("");
lore.add("&eLeft Click &rto download this Script");
lore.add("&eLeft Click &fto download this Script");
lore.add("&4(This will override your current Script)");
if (canRate(p)) {
lore.add("&eShift + Left Click &rto leave a positive Rating");
lore.add("&eShift + Right Click &rto leave a negative Rating");
lore.add("");
lore.add("&eShift + Left Click &fto leave a positive Rating");
lore.add("&eShift + Right Click &fto leave a negative Rating");
}
return new CustomItem(android.getItem(), "&b" + getName(), lore.toArray(new String[0]));

View File

@ -18,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
@ -72,6 +73,14 @@ public class Crucible extends SimpleSlimefunItem<BlockUseHandler> implements Rec
items.add(new ItemStack(Material.LAVA_BUCKET));
}
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
items.add(new ItemStack(Material.BLACKSTONE, 8));
items.add(new ItemStack(Material.LAVA_BUCKET));
items.add(new ItemStack(Material.BASALT, 12));
items.add(new ItemStack(Material.LAVA_BUCKET));
}
return items;
}

View File

@ -8,6 +8,7 @@ import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
@ -89,11 +90,12 @@ public abstract class AbstractEnergyProvider extends SlimefunItem implements Inv
}
public void registerFuel(@Nonnull MachineFuel fuel) {
Validate.notNull(fuel, "Machine Fuel cannot be null!");
fuelTypes.add(fuel);
}
@Nonnull
public Set<MachineFuel> getFuelTypes() {
public Set<MachineFuel> getFuelTypes2() {
return fuelTypes;
}

View File

@ -48,8 +48,6 @@ public abstract class BioGenerator extends AGenerator {
registerFuel(new MachineFuel(20, new ItemStack(Material.DRIED_KELP_BLOCK)));
registerFuel(new MachineFuel(1, new ItemStack(Material.SEAGRASS)));
registerFuel(new MachineFuel(2, new ItemStack(Material.SEA_PICKLE)));
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
registerFuel(new MachineFuel(1, new ItemStack(Material.BAMBOO)));
registerFuel(new MachineFuel(2, new ItemStack(Material.SWEET_BERRIES)));
@ -57,7 +55,6 @@ public abstract class BioGenerator extends AGenerator {
for (Material m : Tag.SMALL_FLOWERS.getValues()) {
registerFuel(new MachineFuel(1, new ItemStack(m)));
}
}
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
registerFuel(new MachineFuel(4, new ItemStack(Material.HONEYCOMB)));

View File

@ -74,7 +74,7 @@ public abstract class CoalGenerator extends AGenerator {
}
// Signs
for (Material mat : Tag.SIGNS.getValues()) {
for (Material mat : Tag.STANDING_SIGNS.getValues()) {
registerFuel(new MachineFuel(2, new ItemStack(mat)));
}
}

View File

@ -4,6 +4,8 @@ import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
@ -29,6 +31,11 @@ public abstract class ElectrifiedCrucible extends AContainer {
for (Material leaves : Tag.LEAVES.getValues()) {
registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(leaves, 16) }, new ItemStack[] { new ItemStack(Material.WATER_BUCKET) });
}
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BLACKSTONE, 8) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) });
registerRecipe(10, new ItemStack[] { new ItemStack(Material.BUCKET), new ItemStack(Material.BASALT, 12) }, new ItemStack[] { new ItemStack(Material.LAVA_BUCKET) });
}
}
@Override

View File

@ -3,10 +3,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
@ -30,11 +28,8 @@ public abstract class FoodComposter extends AContainer implements RecipeDisplayI
registerRecipe(30, new ItemStack[] { SlimefunItems.APPLE_ORGANIC_FOOD }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.APPLE_FERTILIZER, OrganicFertilizer.OUTPUT) });
registerRecipe(30, new ItemStack[] { SlimefunItems.KELP_ORGANIC_FOOD }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.KELP_FERTILIZER, OrganicFertilizer.OUTPUT) });
registerRecipe(30, new ItemStack[] { SlimefunItems.COCOA_ORGANIC_FOOD }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.COCOA_FERTILIZER, OrganicFertilizer.OUTPUT) });
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
registerRecipe(30, new ItemStack[] { SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SWEET_BERRIES_FERTILIZER, OrganicFertilizer.OUTPUT) });
}
}
@Override
public String getMachineIdentifier() {

View File

@ -3,9 +3,7 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.electric.machine
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
@ -29,11 +27,8 @@ public abstract class FoodFabricator extends AContainer {
registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.APPLE) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.APPLE_ORGANIC_FOOD, OrganicFood.OUTPUT) });
registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.DRIED_KELP) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.KELP_ORGANIC_FOOD, OrganicFood.OUTPUT) });
registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.COCOA_BEANS) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.COCOA_ORGANIC_FOOD, OrganicFood.OUTPUT) });
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
registerRecipe(12, new ItemStack[] { SlimefunItems.TIN_CAN, new ItemStack(Material.SWEET_BERRIES) }, new ItemStack[] { new SlimefunItemStack(SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, OrganicFood.OUTPUT) });
}
}
@Override
public String getMachineIdentifier() {

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.magical.talismans;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.NamespacedKey;
import org.bukkit.block.EnderChest;
import org.bukkit.inventory.ItemStack;
@ -21,12 +23,13 @@ class EnderTalisman extends Talisman {
private static final LockedCategory ENDER_TALISMANS_CATEGORY = new LockedCategory(new NamespacedKey(SlimefunPlugin.instance(), "ender_talismans"), new CustomItem(SlimefunItems.ENDER_TALISMAN, "&7Talismans - &aTier II"), 3, Talisman.TALISMANS_CATEGORY.getKey());
@ParametersAreNonnullByDefault
public EnderTalisman(Talisman parent, SlimefunItemStack item) {
super(ENDER_TALISMANS_CATEGORY, item, new ItemStack[] { SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3, null, parent.getItem(), null, SlimefunItems.ENDER_LUMP_3, null, SlimefunItems.ENDER_LUMP_3 }, parent.isConsumable(), parent.isEventCancelled(), parent.getMessageSuffix(), parent.getChance(), parent.getEffects());
}
@Override
public void createEnderTalisman() {
void loadEnderTalisman() {
// Let's override that, otherwise we would be creating Ender Talismans
// for every Ender Talisman
}

View File

@ -7,6 +7,7 @@ import java.util.concurrent.ThreadLocalRandom;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.ChatColor;
import org.bukkit.NamespacedKey;
@ -48,19 +49,23 @@ public class Talisman extends SlimefunItem {
protected final PotionEffect[] effects;
protected final int chance;
public Talisman(SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, PotionEffect... effects) {
@ParametersAreNonnullByDefault
public Talisman(SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, @Nullable String messageSuffix, PotionEffect... effects) {
this(item, recipe, consumable, cancelEvent, messageSuffix, 100, effects);
}
public Talisman(SlimefunItemStack item, ItemStack[] recipe, String messageSuffix, int chance, PotionEffect... effects) {
@ParametersAreNonnullByDefault
public Talisman(SlimefunItemStack item, ItemStack[] recipe, @Nullable String messageSuffix, int chance, PotionEffect... effects) {
this(item, recipe, true, true, messageSuffix, chance, effects);
}
public Talisman(SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, int chance, PotionEffect... effects) {
@ParametersAreNonnullByDefault
public Talisman(SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, @Nullable String messageSuffix, int chance, PotionEffect... effects) {
this(TALISMANS_CATEGORY, item, recipe, consumable, cancelEvent, messageSuffix, chance, effects);
}
protected Talisman(Category category, SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, String messageSuffix, int chance, PotionEffect... effects) {
@ParametersAreNonnullByDefault
protected Talisman(Category category, SlimefunItemStack item, ItemStack[] recipe, boolean consumable, boolean cancelEvent, @Nullable String messageSuffix, int chance, PotionEffect... effects) {
super(category, item, RecipeType.MAGIC_WORKBENCH, recipe, new CustomItem(item, consumable ? 4 : 1));
this.consumable = consumable;
@ -85,14 +90,26 @@ public class Talisman extends SlimefunItem {
}
}
/**
* This returns whether the {@link Talisman} will be consumed upon use.
*
* @return Whether this {@link Talisman} is consumed on use.
*/
public boolean isConsumable() {
return consumable;
}
/**
* This returns the chance of this {@link Talisman} activating.
* The chance will be between 1 and 100.
*
* @return The chance of this {@link Talisman} activating.
*/
public int getChance() {
return chance;
}
@Nonnull
public PotionEffect[] getEffects() {
return effects;
}
@ -105,6 +122,7 @@ public class Talisman extends SlimefunItem {
return cancel;
}
@Nullable
private SlimefunItemStack getEnderVariant() {
return enderTalisman;
}
@ -118,10 +136,10 @@ public class Talisman extends SlimefunItem {
@Override
public void load() {
super.load();
createEnderTalisman();
loadEnderTalisman();
}
protected void createEnderTalisman() {
void loadEnderTalisman() {
EnderTalisman talisman = (EnderTalisman) SlimefunItem.getByItem(getEnderVariant());
Optional<Research> research = Research.getResearch(new NamespacedKey(SlimefunPlugin.instance(), "ender_talismans"));
@ -130,7 +148,7 @@ public class Talisman extends SlimefunItem {
}
}
private static boolean hasMessage(Talisman talisman) {
private static boolean hasMessage(@Nonnull Talisman talisman) {
return talisman.getMessageSuffix() != null;
}
@ -165,14 +183,14 @@ public class Talisman extends SlimefunItem {
ItemStack possibleTalisman = retrieveTalismanFromInventory(p.getInventory(), talisman);
if (possibleTalisman != null && Slimefun.hasUnlocked(p, talisman, true)) {
activateTalisman(e, p, p.getInventory(), talisman);
activateTalisman(e, p, p.getInventory(), talisman, possibleTalisman);
return possibleTalisman;
}
possibleTalisman = retrieveTalismanFromInventory(p.getEnderChest(), talisman);
if (possibleTalisman != null && Slimefun.hasUnlocked(p, talisman, true)) {
activateTalisman(e, p, p.getEnderChest(), talisman);
activateTalisman(e, p, p.getEnderChest(), talisman, possibleTalisman);
return possibleTalisman;
}
@ -182,6 +200,7 @@ public class Talisman extends SlimefunItem {
@Nullable
private static ItemStack retrieveTalismanFromInventory(@Nonnull Inventory inv, @Nonnull Talisman talisman) {
ItemStack[] contents = inv.getContents();
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
@ -193,50 +212,47 @@ public class Talisman extends SlimefunItem {
return null;
}
private static void activateTalisman(Event e, Player p, Inventory inv, Talisman talisman) {
consumeItem(inv, talisman);
@ParametersAreNonnullByDefault
private static void activateTalisman(Event e, Player p, Inventory inv, Talisman talisman, ItemStack talismanItem) {
consumeItem(inv, talisman, talismanItem);
applyTalismanEffects(p, talisman);
cancelEvent(e, talisman);
sendMessage(p, talisman);
}
@ParametersAreNonnullByDefault
private static void applyTalismanEffects(Player p, Talisman talisman) {
for (PotionEffect effect : talisman.getEffects()) {
p.addPotionEffect(effect);
}
}
@ParametersAreNonnullByDefault
private static void cancelEvent(Event e, Talisman talisman) {
if (e instanceof Cancellable && talisman.isEventCancelled()) {
((Cancellable) e).setCancelled(true);
}
}
@ParametersAreNonnullByDefault
private static void sendMessage(Player p, Talisman talisman) {
if (hasMessage(talisman)) {
SlimefunPlugin.getLocalization().sendMessage(p, "messages.talisman." + talisman.getMessageSuffix(), true);
}
}
private static void consumeItem(Inventory inv, Talisman talisman) {
@ParametersAreNonnullByDefault
private static void consumeItem(Inventory inv, Talisman talisman, ItemStack talismanItem) {
if (talisman.isConsumable()) {
ItemStack[] contents = inv.getContents();
for (int i = 0; i < contents.length; i++) {
ItemStack item = contents[i];
if (SlimefunUtils.isItemSimilar(item, talisman.getItem(), true, false)) {
ItemUtils.consumeItem(item, false);
return;
}
}
ItemUtils.consumeItem(talismanItem, false);
}
}
private static Player getPlayerByEventType(Event e) {
@Nullable
private static Player getPlayerByEventType(@Nonnull Event e) {
if (e instanceof PlayerDeathEvent) {
return ((PlayerDeathEvent) e).getEntity();
}
else if (e instanceof EntityDeathEvent) {
} else if (e instanceof EntityDeathEvent) {
return ((EntityDeathEvent) e).getEntity().getKiller();
} else if (e instanceof BlockBreakEvent) {
return ((BlockBreakEvent) e).getPlayer();
@ -253,7 +269,7 @@ public class Talisman extends SlimefunItem {
return null;
}
private static boolean pass(Player p, SlimefunItem talisman) {
private static boolean pass(@Nonnull Player p, @Nonnull SlimefunItem talisman) {
for (PotionEffect effect : ((Talisman) talisman).getEffects()) {
if (effect != null && p.hasPotionEffect(effect.getType())) {
return false;

View File

@ -1,14 +1,25 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
import javax.annotation.Nonnull;
import java.util.Optional;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.GameMode;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.entity.Piglin;
import org.bukkit.entity.Sheep;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.core.attributes.PiglinBarterDrop;
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler;
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import io.github.thebusybiscuit.slimefun4.implementation.items.magical.VillagerRune;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
@ -16,9 +27,6 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import javax.annotation.Nonnull;
import java.util.Optional;
/**
* This {@link SlimefunItem} can only be obtained via bartering with a {@link Piglin}, its
* only current uses is the recipe for crafting the {@link VillagerRune}.
@ -37,6 +45,7 @@ public class StrangeNetherGoo extends SimpleSlimefunItem<ItemUseHandler> impleme
super(category, item, recipeType, recipe);
addItemSetting(chance);
addItemHandler(onRightClickEntity());
}
@Override
@ -56,4 +65,27 @@ public class StrangeNetherGoo extends SimpleSlimefunItem<ItemUseHandler> impleme
};
}
private EntityInteractHandler onRightClickEntity() {
return (e, item, hand) -> {
if (e.getRightClicked() instanceof Sheep) {
Sheep s = (Sheep) e.getRightClicked();
if (s.getCustomName() != null) {
e.setCancelled(true);
return;
}
if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
ItemUtils.consumeItem(item, false);
}
// Give Sheep color, name and effect
s.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 60, 2));
s.setColor(DyeColor.PURPLE);
s.setCustomName(ChatColor.DARK_PURPLE + "Tainted Sheep");
e.setCancelled(true);
}
};
}
}

View File

@ -2,6 +2,8 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks;
import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.block.Block;
@ -14,7 +16,6 @@ import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.papermc.lib.PaperLib;
@ -23,7 +24,7 @@ import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.Slimefun;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class ArmorForge extends MultiBlockMachine {
public class ArmorForge extends BackpackCrafter {
public ArmorForge(Category category, SlimefunItemStack item) {
super(category, item, new ItemStack[] { null, null, null, null, new ItemStack(Material.ANVIL), null, null, new CustomItem(Material.DISPENSER, "Dispenser (Facing up)"), null }, BlockFace.SELF);
@ -31,8 +32,8 @@ public class ArmorForge extends MultiBlockMachine {
@Override
public void onInteract(Player p, Block b) {
Block dispBlock = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispBlock, false).getState();
Block dispenser = b.getRelative(BlockFace.DOWN);
BlockState state = PaperLib.getBlockState(dispenser, false).getState();
if (state instanceof Dispenser) {
Dispenser disp = (Dispenser) state;
@ -44,13 +45,7 @@ public class ArmorForge extends MultiBlockMachine {
ItemStack output = RecipeType.getRecipeOutputList(this, inputs.get(i)).clone();
if (Slimefun.hasUnlocked(p, output, true)) {
Inventory outputInv = findOutputInventory(output, dispBlock, inv);
if (outputInv != null) {
craft(p, output, inv, outputInv);
} else {
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
}
craft(p, output, inv, dispenser);
}
return;
@ -71,7 +66,12 @@ public class ArmorForge extends MultiBlockMachine {
return true;
}
private void craft(Player p, ItemStack output, Inventory inv, Inventory outputInv) {
@ParametersAreNonnullByDefault
private void craft(Player p, ItemStack output, Inventory inv, Block dispenser) {
Inventory fakeInv = createVirtualInventory(inv);
Inventory outputInv = findOutputInventory(output, dispenser, inv, fakeInv);
if (outputInv != null) {
for (int j = 0; j < 9; j++) {
ItemStack item = inv.getContents()[j];
@ -92,6 +92,10 @@ public class ArmorForge extends MultiBlockMachine {
}
}, j * 20L);
}
} else {
SlimefunPlugin.getLocalization().sendMessage(p, "machines.full-inventory", true);
}
}
}

View File

@ -32,6 +32,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*
* @see EnhancedCraftingTable
* @see MagicWorkbench
* @see ArmorForge
*
*/
abstract class BackpackCrafter extends MultiBlockMachine {

View File

@ -15,7 +15,6 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
@ -27,8 +26,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
public class PressureChamber extends MultiBlockMachine {
public PressureChamber(Category category, SlimefunItemStack item) {
super(category, item, new ItemStack[] { SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), SlimefunPlugin.getMinecraftVersion()
.isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? new ItemStack(Material.SMOOTH_STONE_SLAB) : new ItemStack(Material.STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP);
super(category, item, new ItemStack[] { new ItemStack(Material.SMOOTH_STONE_SLAB), new CustomItem(Material.DISPENSER, "Dispenser (Facing down)"), new ItemStack(Material.SMOOTH_STONE_SLAB), new ItemStack(Material.PISTON), new ItemStack(Material.GLASS), new ItemStack(Material.PISTON), new ItemStack(Material.PISTON), new ItemStack(Material.CAULDRON), new ItemStack(Material.PISTON) }, BlockFace.UP);
}
@Override

View File

@ -52,7 +52,7 @@ public class IndustrialMiner extends MultiBlockMachine {
private final ItemSetting<Boolean> canMineAncientDebris = new ItemSetting<>("can-mine-ancient-debris", false);
public IndustrialMiner(Category category, SlimefunItemStack item, Material baseMaterial, boolean silkTouch, int range) {
super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14) ? Material.BLAST_FURNACE : Material.FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP);
super(category, item, new ItemStack[] { null, null, null, new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(Material.CHEST), new CustomItem(Material.PISTON, "Piston (facing up)"), new ItemStack(baseMaterial), new ItemStack(Material.BLAST_FURNACE), new ItemStack(baseMaterial) }, BlockFace.UP);
this.range = range;
this.silkTouch = silkTouch;

View File

@ -55,7 +55,7 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
Player p = e.getPlayer();
Block b = e.getBlock();
b.getWorld().createExplosion(b.getLocation(), 0.0F);
b.getWorld().createExplosion(b.getLocation(), 0);
b.getWorld().playSound(b.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.2F, 1F);
List<Block> blocks = findBlocks(b);
@ -122,8 +122,9 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
private void breakBlock(Player p, ItemStack item, Block b, int fortune, List<ItemStack> drops) {
SlimefunPlugin.getProtectionManager().logAction(p, b, ProtectableAction.BREAK_BLOCK);
Material material = b.getType();
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
b.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, material);
SlimefunItem sfItem = BlockStorage.check(b);
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
@ -132,10 +133,10 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) {
drops.add(BlockStorage.retrieve(b));
}
} else if (b.getType() == Material.PLAYER_HEAD || b.getType() == Material.SHULKER_BOX || b.getType().name().endsWith("_SHULKER_BOX")) {
} else if (material == Material.PLAYER_HEAD || SlimefunTag.SHULKER_BOXES.isTagged(material)) {
b.breakNaturally(item);
} else {
boolean applyFortune = b.getType().name().endsWith("_ORE") && b.getType() != Material.IRON_ORE && b.getType() != Material.GOLD_ORE;
boolean applyFortune = SlimefunTag.FORTUNE_COMPATIBLE_ORES.isTagged(material);
for (ItemStack drop : b.getDrops(getItem())) {
// For some reason this check is necessary with Paper

View File

@ -39,6 +39,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
* and {@link BlockBreakEvent}.
*
* @author TheBusyBiscuit
* @author Linox
*
* @see BlockPlaceHandler
* @see BlockBreakHandler
@ -51,17 +52,22 @@ public class BlockListener implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent e) {
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBlockPlaceExisting(BlockPlaceEvent e) {
// This prevents Players from placing a block where another block already exists
// While this can cause ghost blocks it also prevents them from replacing grass
// or saplings etc...
if (BlockStorage.hasBlockInfo(e.getBlock())) {
e.setCancelled(true);
return;
}
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent e) {
ItemStack item = e.getItemInHand();
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && Slimefun.isEnabled(e.getPlayer(), sfItem, true) && !(sfItem instanceof NotPlaceable)) {
if (sfItem != null && !(sfItem instanceof NotPlaceable) && Slimefun.isEnabled(e.getPlayer(), sfItem, true)) {
if (!Slimefun.hasUnlocked(e.getPlayer(), sfItem, true)) {
e.setCancelled(true);
} else {
@ -75,8 +81,13 @@ public class BlockListener implements Listener {
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent e) {
if (SlimefunPlugin.getThirdPartySupportService().isEventFaked(e)) {
// This is a "fake" event, we can ignore it.
return;
}
checkForSensitiveBlockAbove(e.getPlayer(), e.getBlock());
ItemStack item = e.getPlayer().getInventory().getItemInMainHand();
@ -94,6 +105,7 @@ public class BlockListener implements Listener {
dropItems(e, drops);
}
@ParametersAreNonnullByDefault
private void callToolHandler(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
SlimefunItem tool = SlimefunItem.getByItem(item);
@ -106,6 +118,7 @@ public class BlockListener implements Listener {
}
}
@ParametersAreNonnullByDefault
private void callBlockHandler(BlockBreakEvent e, ItemStack item, int fortune, List<ItemStack> drops) {
SlimefunItem sfItem = BlockStorage.check(e.getBlock());
@ -183,16 +196,19 @@ public class BlockListener implements Listener {
}
private int getBonusDropsWithFortune(@Nullable ItemStack item, @Nonnull Block b) {
int fortune = 1;
int amount = 1;
if (item != null && item.getEnchantments().containsKey(Enchantment.LOOT_BONUS_BLOCKS) && !item.getEnchantments().containsKey(Enchantment.SILK_TOUCH)) {
Random random = ThreadLocalRandom.current();
if (item != null) {
int fortuneLevel = item.getEnchantmentLevel(Enchantment.LOOT_BONUS_BLOCKS);
fortune = Math.max(1, random.nextInt(fortuneLevel + 2) - 1);
fortune = (b.getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (fortune + 1);
if (fortuneLevel > 0 && !item.containsEnchantment(Enchantment.SILK_TOUCH)) {
Random random = ThreadLocalRandom.current();
amount = Math.max(1, random.nextInt(fortuneLevel + 2) - 1);
amount = (b.getType() == Material.LAPIS_ORE ? 4 + random.nextInt(5) : 1) * (amount + 1);
}
}
return fortune;
return amount;
}
}

View File

@ -39,16 +39,20 @@ public class SlimefunBootsListener implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onDamage(EntityDamageEvent e) {
if (e.getEntity() instanceof Player) {
if (e.getCause() == DamageCause.FALL) {
if (e.getEntity() instanceof Player && e.getCause() == DamageCause.FALL) {
onFallDamage(e);
} else if (e instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
if (event.getDamager() instanceof EnderPearl) {
onEnderPearlDamage(e);
}
}
@EventHandler
public void onEnderPearlDamage(EntityDamageByEntityEvent e) {
if (e.getDamager() instanceof EnderPearl && e.getEntity() instanceof Player) {
Player p = (Player) e.getEntity();
SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots());
if (boots != null && boots.getId().equals("ENDER_BOOTS") && Slimefun.hasUnlocked(p, boots, true)) {
e.setCancelled(true);
}
}
}
@ -71,15 +75,6 @@ public class SlimefunBootsListener implements Listener {
}
}
private void onEnderPearlDamage(@Nonnull EntityDamageEvent e) {
Player p = (Player) e.getEntity();
SlimefunItem boots = SlimefunItem.getByItem(p.getInventory().getBoots());
if (boots != null && boots.getId().equals("ENDER_BOOTS") && Slimefun.hasUnlocked(p, boots, true)) {
e.setCancelled(true);
}
}
@EventHandler
public void onTrample(PlayerInteractEvent e) {
if (e.getAction() == Action.PHYSICAL) {

View File

@ -1,158 +0,0 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a vanilla
* machine like the workbench, grindstone, brewing stand or an anvil.
*
* @author TheBusyBiscuit
* @author NathanAdhitya
* @author Steve
* @author VoidAngel
*
*/
public class VanillaMachinesListener implements Listener {
public VanillaMachinesListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled = true)
public void onGrindstone(InventoryClickEvent e) {
// The Grindstone was only ever added in MC 1.14
if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
return;
}
if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];
if (checkForUnallowedItems(item1, item2)) {
e.setResult(Result.DENY);
}
}
}
@EventHandler
public void onCraft(CraftItemEvent e) {
for (ItemStack item : e.getInventory().getContents()) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !sfItem.isUseableInWorkbench()) {
e.setResult(Result.DENY);
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "workbench.not-enhanced", true);
break;
}
}
}
@EventHandler
public void onPrepareCraft(PrepareItemCraftEvent e) {
if (e.getInventory().getResult() != null) {
for (ItemStack item : e.getInventory().getContents()) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !sfItem.isUseableInWorkbench()) {
e.getInventory().setResult(null);
break;
}
}
}
}
@EventHandler(ignoreCancelled = true)
public void onAnvil(InventoryClickEvent e) {
if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.ANVIL && e.getWhoClicked() instanceof Player) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];
if (checkForUnallowedItems(item1, item2)) {
e.setResult(Result.DENY);
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "anvil.not-working", true);
}
}
}
@EventHandler(ignoreCancelled = true)
public void onCartographyTable(InventoryClickEvent e) {
// The Cartography Table was only ever added in MC 1.14
if (!SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
return;
}
if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];
if (checkForUnallowedItems(item1, item2)) {
e.setResult(Result.DENY);
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "cartography_table.not-working", true);
}
}
}
@EventHandler(ignoreCancelled = true)
public void onPreBrew(InventoryClickEvent e) {
Inventory clickedInventory = e.getClickedInventory();
Inventory topInventory = e.getView().getTopInventory();
if (clickedInventory != null && topInventory.getType() == InventoryType.BREWING && topInventory.getHolder() instanceof BrewingStand) {
if (e.getAction() == InventoryAction.HOTBAR_SWAP) {
e.setCancelled(true);
return;
}
if (clickedInventory.getType() == InventoryType.BREWING) {
e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor())));
} else {
e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCurrentItem())));
}
if (e.getResult() == Result.DENY) {
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "brewing_stand.not-working", true);
}
}
}
private boolean checkForUnallowedItems(@Nullable ItemStack item1, @Nullable ItemStack item2) {
if (SlimefunGuide.isGuideItem(item1) || SlimefunGuide.isGuideItem(item2)) {
return true;
} else {
SlimefunItem sfItem1 = SlimefunItem.getByItem(item1);
SlimefunItem sfItem2 = SlimefunItem.getByItem(item2);
if (isUnallowed(sfItem1) || isUnallowed(sfItem2)) {
return true;
}
}
return false;
}
private boolean isUnallowed(@Nullable SlimefunItem item) {
return item != null && !(item instanceof VanillaItem) && !item.isDisabled();
}
}

View File

@ -0,0 +1,43 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nonnull;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a
* {@link BrewingStand}.
*
* @author TheBusyBiscuit
*
*/
public class AnvilListener implements SlimefunCraftingListener {
public AnvilListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled = true)
public void onAnvil(InventoryClickEvent e) {
if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.ANVIL && e.getWhoClicked() instanceof Player) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];
if (hasUnallowedItems(item1, item2)) {
e.setResult(Result.DENY);
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "anvil.not-working", true);
}
}
}
}

View File

@ -0,0 +1,55 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nonnull;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a
* {@link BrewingStand}.
*
* @author VoidAngel
* @author SoSeDiK
*
*/
public class BrewingStandListener implements SlimefunCraftingListener {
public BrewingStandListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled = true)
public void onPreBrew(InventoryClickEvent e) {
Inventory clickedInventory = e.getClickedInventory();
Inventory topInventory = e.getView().getTopInventory();
if (clickedInventory != null && topInventory.getType() == InventoryType.BREWING && topInventory.getHolder() instanceof BrewingStand) {
if (e.getAction() == InventoryAction.HOTBAR_SWAP) {
e.setCancelled(true);
return;
}
if (clickedInventory.getType() == InventoryType.BREWING) {
e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCursor())));
} else {
e.setCancelled(isUnallowed(SlimefunItem.getByItem(e.getCurrentItem())));
}
if (e.getResult() == Result.DENY) {
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "brewing_stand.not-working", true);
}
}
}
}

View File

@ -0,0 +1,42 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nonnull;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a
* cartography table.
*
* @author poma123
*
*/
public class CartographyTableListener implements SlimefunCraftingListener {
public CartographyTableListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled = true)
public void onCartographyTable(InventoryClickEvent e) {
if (e.getRawSlot() == 2 && e.getInventory().getType() == InventoryType.CARTOGRAPHY && e.getWhoClicked() instanceof Player) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];
if (hasUnallowedItems(item1, item2)) {
e.setResult(Result.DENY);
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "cartography_table.not-working", true);
}
}
}
}

View File

@ -0,0 +1,52 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nonnull;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a
* Cauldron.
* This is mainly used to prevent the discoloring of leather armor.
*
* @author TheBusyBiscuit
*
*/
public class CauldronListener implements SlimefunCraftingListener {
public CauldronListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onCauldronUse(PlayerInteractEvent e) {
if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
Block block = e.getClickedBlock();
if (block.getType() == Material.CAULDRON) {
ItemStack item = e.getItem();
if (item != null && SlimefunTag.LEATHER_ARMOR.isTagged(item.getType())) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (isUnallowed(sfItem)) {
e.setCancelled(true);
SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "cauldron.no-discoloring");
}
}
}
}
}
}

View File

@ -0,0 +1,56 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nonnull;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a
* crafting table.
*
* @author TheBusyBiscuit
*
*/
public class CraftingTableListener implements SlimefunCraftingListener {
public CraftingTableListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler
public void onCraft(CraftItemEvent e) {
for (ItemStack item : e.getInventory().getContents()) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !sfItem.isUseableInWorkbench()) {
e.setResult(Result.DENY);
SlimefunPlugin.getLocalization().sendMessage((Player) e.getWhoClicked(), "workbench.not-enhanced", true);
break;
}
}
}
@EventHandler
public void onPrepareCraft(PrepareItemCraftEvent e) {
if (e.getInventory().getResult() != null) {
for (ItemStack item : e.getInventory().getContents()) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
if (sfItem != null && !sfItem.isUseableInWorkbench()) {
e.getInventory().setResult(null);
break;
}
}
}
}
}

View File

@ -0,0 +1,42 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nonnull;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
/**
* This {@link Listener} prevents any {@link SlimefunItem} from being used in a
* cartography table.
*
* @author NathanAdhitya
*
*/
public class GrindstoneListener implements SlimefunCraftingListener {
public GrindstoneListener(@Nonnull SlimefunPlugin plugin) {
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
@EventHandler(ignoreCancelled = true)
public void onGrindstone(InventoryClickEvent e) {
if (e.getRawSlot() == 2 && e.getWhoClicked() instanceof Player && e.getInventory().getType() == InventoryType.GRINDSTONE) {
ItemStack item1 = e.getInventory().getContents()[0];
ItemStack item2 = e.getInventory().getContents()[1];
if (hasUnallowedItems(item1, item2)) {
e.setResult(Result.DENY);
}
}
}
}

View File

@ -0,0 +1,42 @@
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;
import javax.annotation.Nullable;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.slimefun4.core.guide.SlimefunGuide;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
interface SlimefunCraftingListener extends Listener {
default boolean hasUnallowedItems(@Nullable ItemStack item1, @Nullable ItemStack item2) {
if (SlimefunGuide.isGuideItem(item1) || SlimefunGuide.isGuideItem(item2)) {
return true;
} else {
SlimefunItem sfItem1 = SlimefunItem.getByItem(item1);
SlimefunItem sfItem2 = SlimefunItem.getByItem(item2);
if (isUnallowed(sfItem1) || isUnallowed(sfItem2)) {
return true;
}
}
return false;
}
default boolean isUnallowed(@Nullable ItemStack item) {
if (item == null) {
return false;
}
SlimefunItem sfItem = SlimefunItem.getByItem(item);
return !(sfItem instanceof VanillaItem) && !sfItem.isDisabled();
}
default boolean isUnallowed(@Nullable SlimefunItem item) {
return item != null && !(item instanceof VanillaItem) && !item.isDisabled();
}
}

View File

@ -0,0 +1,5 @@
/**
* This package holds every {@link org.bukkit.event.Listener} which is responsible for preventing that a
* {@link me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem} is used in an unallowed crafting operation
*/
package io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting;

View File

@ -208,27 +208,8 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
*/
public final class SlimefunItemSetup {
private static final Material RED_DYE;
private static final Material YELLOW_DYE;
private static final Material BLACK_DYE;
private static final Material GREEN_DYE;
private static boolean registeredItems = false;
static {
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
RED_DYE = Material.RED_DYE;
YELLOW_DYE = Material.YELLOW_DYE;
BLACK_DYE = Material.BLACK_DYE;
GREEN_DYE = Material.GREEN_DYE;
} else {
RED_DYE = Material.valueOf("ROSE_RED");
YELLOW_DYE = Material.valueOf("DANDELION_YELLOW");
BLACK_DYE = Material.valueOf("INK_SAC");
GREEN_DYE = Material.valueOf("CACTUS_GREEN");
}
}
private SlimefunItemSetup() {}
public static void setup(@Nonnull SlimefunPlugin plugin) {
@ -239,6 +220,7 @@ public final class SlimefunItemSetup {
registeredItems = true;
DefaultCategories categories = new DefaultCategories();
// @formatter:off (We will need to refactor this one day)
new SlimefunItem(categories.weapons, SlimefunItems.GRANDMAS_WALKING_STICK, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, new ItemStack(Material.OAK_LOG), null, null, new ItemStack(Material.OAK_LOG), null, null, new ItemStack(Material.OAK_LOG), null})
.register(plugin);
@ -797,7 +779,6 @@ public final class SlimefunItemSetup {
new ItemStack[] {null, null, SlimefunItems.LAVA_CRYSTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, SlimefunItems.STAFF_ELEMENTAL, null, null})
.register(plugin);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new StormStaff(categories.magicalGadgets, SlimefunItems.STAFF_STORM, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {SlimefunItems.LIGHTNING_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.LIGHTNING_RUNE, SlimefunItems.STAFF_WATER, SlimefunItems.MAGIC_SUGAR, SlimefunItems.STAFF_WIND, SlimefunItems.LIGHTNING_RUNE, SlimefunItems.ENDER_LUMP_3, SlimefunItems.LIGHTNING_RUNE})
.register(plugin);
@ -811,7 +792,6 @@ public final class SlimefunItemSetup {
new ItemStack[] {new ItemStack(Material.GOLD_INGOT), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.GOLD_INGOT), new ItemStack(Material.APPLE), weaknessPotion, new ItemStack(Material.APPLE), new ItemStack(Material.GOLD_INGOT), SlimefunItems.MAGIC_LUMP_2, new ItemStack(Material.GOLD_INGOT)},
new SlimefunItemStack(SlimefunItems.MAGICAL_ZOMBIE_PILLS, 2))
.register(plugin);
}
new SmeltersPickaxe(categories.tools, SlimefunItems.SMELTERS_PICKAXE, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.LAVA_CRYSTAL, SlimefunItems.LAVA_CRYSTAL, SlimefunItems.LAVA_CRYSTAL, null, SlimefunItems.FERROSILICON, null, null, SlimefunItems.FERROSILICON, null})
@ -1036,9 +1016,7 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.HARDENED_METAL_INGOT, SlimefunItems.HARDENED_METAL_INGOT, SlimefunItems.HARDENED_METAL_INGOT, null, SlimefunItems.FERROSILICON, null, null, SlimefunItems.FERROSILICON, null})
.register(plugin);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new TableSaw(categories.basicMachines, SlimefunItems.TABLE_SAW).register(plugin);
}
new SlimefunArmorPiece(categories.magicalArmor, SlimefunItems.SLIME_HELMET_STEEL, RecipeType.ARMOR_FORGE,
new ItemStack[] {new ItemStack(Material.SLIME_BALL), SlimefunItems.STEEL_PLATE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), null, new ItemStack(Material.SLIME_BALL), null, null, null}, null)
@ -1125,7 +1103,7 @@ public final class SlimefunItemSetup {
new RestoredBackpack(categories.usefulItems).register(plugin);
new SlimefunItem(categories.technicalComponents, SlimefunItems.MAGNET, RecipeType.SMELTERY,
new UnplaceableBlock(categories.technicalComponents, SlimefunItems.MAGNET, RecipeType.SMELTERY,
new ItemStack[] {SlimefunItems.NICKEL_INGOT, SlimefunItems.ALUMINUM_DUST, SlimefunItems.IRON_DUST, SlimefunItems.COBALT_INGOT, null, null, null, null, null})
.register(plugin);
@ -1268,11 +1246,9 @@ public final class SlimefunItemSetup {
new ItemStack[] {new ItemStack(Material.PUMPKIN), null, null, null, null, null, null, null, null})
.register(plugin);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new Juice(categories.food, SlimefunItems.SWEET_BERRY_JUICE, RecipeType.JUICER,
new ItemStack[] {new ItemStack(Material.SWEET_BERRIES), null, null, null, null, null, null, null, null})
.register(plugin);
}
new Juice(categories.food, SlimefunItems.GOLDEN_APPLE_JUICE, RecipeType.JUICER,
new ItemStack[] {new ItemStack(Material.GOLDEN_APPLE), null, null, null, null, null, null, null, null})
@ -1338,15 +1314,15 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.CARBONADO, SlimefunItems.BASIC_CIRCUIT_BOARD, SlimefunItems.CARBONADO, SlimefunItems.HEATING_COIL, SlimefunItems.REINFORCED_FURNACE, SlimefunItems.HEATING_COIL, SlimefunItems.CARBONADO, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.CARBONADO})
.register(plugin);
new SlimefunItem(categories.technicalComponents, SlimefunItems.ELECTRO_MAGNET, RecipeType.ENHANCED_CRAFTING_TABLE,
new UnplaceableBlock(categories.technicalComponents, SlimefunItems.ELECTRO_MAGNET, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.NICKEL_INGOT, SlimefunItems.MAGNET, SlimefunItems.COBALT_INGOT, null, SlimefunItems.BATTERY, null, null, null, null})
.register(plugin);
new SlimefunItem(categories.technicalComponents, SlimefunItems.ELECTRIC_MOTOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new UnplaceableBlock(categories.technicalComponents, SlimefunItems.ELECTRIC_MOTOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, null, SlimefunItems.ELECTRO_MAGNET, null, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE})
.register(plugin);
new SlimefunItem(categories.technicalComponents, SlimefunItems.HEATING_COIL, RecipeType.ENHANCED_CRAFTING_TABLE,
new UnplaceableBlock(categories.technicalComponents, SlimefunItems.HEATING_COIL, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE, SlimefunItems.COPPER_WIRE})
.register(plugin);
@ -1490,7 +1466,7 @@ public final class SlimefunItemSetup {
new SlimefunItemStack(SlimefunItems.HARDENED_GLASS, 16))
.register(plugin);
new SlimefunItem(categories.technicalComponents, SlimefunItems.COOLING_UNIT, RecipeType.ENHANCED_CRAFTING_TABLE,
new UnplaceableBlock(categories.technicalComponents, SlimefunItems.COOLING_UNIT, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {new ItemStack(Material.ICE), new ItemStack(Material.ICE), new ItemStack(Material.ICE), SlimefunItems.ALUMINUM_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.ALUMINUM_INGOT, new ItemStack(Material.ICE), new ItemStack(Material.ICE), new ItemStack(Material.ICE)})
.register(plugin);
@ -1999,11 +1975,9 @@ public final class SlimefunItemSetup {
}.register(plugin);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new AutoDrier(categories.electricity, SlimefunItems.AUTO_DRIER, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[]{null, null, null, SlimefunItems.HEATING_COIL, new ItemStack(Material.SMOKER), SlimefunItems.HEATING_COIL, null, new ItemStack(Material.CAMPFIRE), null})
.register(plugin);
}
new AutoBrewer(categories.electricity, SlimefunItems.AUTO_BREWER, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {null, SlimefunItems.HEATING_COIL, null, SlimefunItems.REINFORCED_PLATE, new ItemStack(Material.BREWING_STAND), SlimefunItems.REINFORCED_PLATE, null, SlimefunItems.ELECTRIC_MOTOR, null}) {
@ -2292,7 +2266,7 @@ public final class SlimefunItemSetup {
.register(plugin);
new SlimefunItem(categories.magicalResources, SlimefunItems.RAINBOW_RUNE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.CYAN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.ENDER_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(YELLOW_DYE), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.MAGENTA_DYE)})
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.MAGIC_LUMP_3, new ItemStack(Material.CYAN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.ENDER_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.YELLOW_DYE), SlimefunItems.ENDER_LUMP_3, new ItemStack(Material.MAGENTA_DYE)})
.register(plugin);
new SoulboundRune(categories.magicalResources, SlimefunItems.SOULBOUND_RUNE, RecipeType.ANCIENT_ALTAR,
@ -2361,96 +2335,96 @@ public final class SlimefunItemSetup {
// Christmas
new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_WOOL_XMAS, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_XMAS, 2), new RainbowTickHandler(Material.RED_WOOL, Material.GREEN_WOOL))
.register(plugin);
new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_GLASS_XMAS, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_XMAS, 2), new RainbowTickHandler(Material.RED_STAINED_GLASS, Material.GREEN_STAINED_GLASS))
.register(plugin);
new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_GLASS_PANE_XMAS, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_XMAS, 2), new RainbowTickHandler(Material.RED_STAINED_GLASS_PANE, Material.GREEN_STAINED_GLASS_PANE))
.register(plugin);
new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_CLAY_XMAS, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_XMAS, 2), new RainbowTickHandler(Material.RED_TERRACOTTA, Material.GREEN_TERRACOTTA))
.register(plugin);
new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_CONCRETE_XMAS, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_XMAS, 2), new RainbowTickHandler(Material.RED_CONCRETE, Material.GREEN_CONCRETE))
.register(plugin);
new RainbowBlock(categories.christmas, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(GREEN_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.GREEN_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.GREEN_DYE), SlimefunItems.CHRISTMAS_COOKIE, new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_XMAS, 2), new RainbowTickHandler(Material.RED_GLAZED_TERRACOTTA, Material.GREEN_GLAZED_TERRACOTTA))
.register(plugin);
// Valentines Day
new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_WOOL_VALENTINE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_WOOL, Material.PINK_WOOL))
.register(plugin);
new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_GLASS_VALENTINE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS, Material.PINK_STAINED_GLASS))
.register(plugin);
new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_STAINED_GLASS_PANE, Material.PINK_STAINED_GLASS_PANE))
.register(plugin);
new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_CLAY_VALENTINE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_TERRACOTTA, Material.PINK_TERRACOTTA))
.register(plugin);
new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_CONCRETE_VALENTINE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_CONCRETE, Material.PINK_CONCRETE))
.register(plugin);
new RainbowBlock(categories.valentinesDay, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(RED_DYE)},
new ItemStack[] {new ItemStack(Material.RED_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.PINK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.PINK_DYE), new ItemStack(Material.POPPY), new ItemStack(Material.RED_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_VALENTINE, 2), new RainbowTickHandler(Material.MAGENTA_GLAZED_TERRACOTTA, Material.PINK_GLAZED_TERRACOTTA))
.register(plugin);
// Halloween
new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_WOOL_HALLOWEEN, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_WOOL), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_WOOL_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_WOOL, Material.BLACK_WOOL))
.register(plugin);
new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_GLASS_HALLOWEEN, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS, Material.BLACK_STAINED_GLASS))
.register(plugin);
new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_STAINED_GLASS_PANE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_STAINED_GLASS_PANE), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLASS_PANE_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_STAINED_GLASS_PANE, Material.BLACK_STAINED_GLASS_PANE))
.register(plugin);
new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_CLAY_HALLOWEEN, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_TERRACOTTA), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_CLAY_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_TERRACOTTA, Material.BLACK_TERRACOTTA))
.register(plugin);
new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_CONCRETE), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_CONCRETE), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_CONCRETE_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_CONCRETE, Material.BLACK_CONCRETE))
.register(plugin);
new RainbowBlock(categories.halloween, SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, RecipeType.ANCIENT_ALTAR,
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(BLACK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new ItemStack[] {new ItemStack(Material.ORANGE_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), SlimefunItems.RAINBOW_RUNE, new ItemStack(Material.WHITE_GLAZED_TERRACOTTA), new ItemStack(Material.BLACK_DYE), new ItemStack(Material.PUMPKIN), new ItemStack(Material.ORANGE_DYE)},
new SlimefunItemStack(SlimefunItems.RAINBOW_GLAZED_TERRACOTTA_HALLOWEEN, 2), new RainbowTickHandler(Material.ORANGE_GLAZED_TERRACOTTA, Material.BLACK_GLAZED_TERRACOTTA))
.register(plugin);
@ -2688,10 +2662,8 @@ public final class SlimefunItemSetup {
new OrganicFood(categories.misc, SlimefunItems.APPLE_ORGANIC_FOOD, Material.APPLE)
.register(plugin);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new OrganicFood(categories.misc, SlimefunItems.SWEET_BERRIES_ORGANIC_FOOD, Material.SWEET_BERRIES)
.register(plugin);
}
new OrganicFood(categories.misc, SlimefunItems.KELP_ORGANIC_FOOD, Material.DRIED_KELP)
.register(plugin);
@ -2906,7 +2878,7 @@ public final class SlimefunItemSetup {
}.register(plugin);
new SlimefunItem(categories.cargo, SlimefunItems.CARGO_MOTOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new UnplaceableBlock(categories.cargo, SlimefunItems.CARGO_MOTOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.HARDENED_GLASS, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.HARDENED_GLASS, SlimefunItems.SILVER_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.SILVER_INGOT, SlimefunItems.HARDENED_GLASS, SlimefunItems.ELECTRO_MAGNET, SlimefunItems.HARDENED_GLASS},
new SlimefunItemStack(SlimefunItems.CARGO_MOTOR, 4))
.register(plugin);
@ -3069,11 +3041,9 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.BLISTERING_INGOT_3, new ItemStack(Material.NETHER_STAR), SlimefunItems.BLISTERING_INGOT_3, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ANDROID_MEMORY_CORE, SlimefunItems.WITHER_PROOF_OBSIDIAN, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.CARBONADO_EDGED_CAPACITOR})
.register(plugin);
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new TapeMeasure(categories.usefulItems, SlimefunItems.TAPE_MEASURE, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.SILICON, new ItemStack(Material.YELLOW_DYE), SlimefunItems.SILICON, new ItemStack(Material.YELLOW_DYE), new ItemStack(Material.STRING), new ItemStack(Material.YELLOW_DYE), SlimefunItems.GILDED_IRON, new ItemStack(Material.YELLOW_DYE), SlimefunItems.SILICON})
.register(plugin);
}
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_16)) {
new StrangeNetherGoo(categories.magicalResources, SlimefunItems.STRANGE_NETHER_GOO, RecipeType.BARTER_DROP,
@ -3089,6 +3059,8 @@ public final class SlimefunItemSetup {
new ElytraCap(categories.magicalArmor, SlimefunItems.ELYTRA_CAP, RecipeType.ARMOR_FORGE,
new ItemStack[]{new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.SLIME_BALL), SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, SlimefunItems.ELYTRA_SCALE, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.LEATHER_HELMET), new ItemStack(Material.SLIME_BALL)})
.register(plugin);
// @formatter:on
}
private static void registerArmorSet(Category category, ItemStack baseComponent, ItemStack[] items, String idSyntax, boolean vanilla, PotionEffect[][] effects, SlimefunAddon addon) {

View File

@ -29,6 +29,9 @@ public final class ChestMenuUtils {
private static final ItemStack INPUT_SLOT = new SlimefunItemStack("_UI_INPUT_SLOT", Material.CYAN_STAINED_GLASS_PANE, " ");
private static final ItemStack OUTPUT_SLOT = new SlimefunItemStack("_UI_OUTPUT_SLOT", Material.ORANGE_STAINED_GLASS_PANE, " ");
private static final ItemStack NO_PERMISSION = new SlimefunItemStack("_UI_NO_PERMISSION", Material.BARRIER, "No Permission");
private static final ItemStack NOT_RESEARCHED = new SlimefunItemStack("_UI_NOT_RESEARCHED", Material.BARRIER, "Not researched");
private static final ItemStack BACK_BUTTON = new SlimefunItemStack("_UI_BACK", Material.ENCHANTED_BOOK, "&7\u21E6 Back", meta -> meta.addItemFlags(ItemFlag.HIDE_ENCHANTS));
private static final ItemStack MENU_BUTTON = new SlimefunItemStack("_UI_MENU", Material.COMPARATOR, "&eSettings / Info", "", "&7\u21E8 Click to see more");
private static final ItemStack SEARCH_BUTTON = new SlimefunItemStack("_UI_SEARCH", Material.NAME_TAG, "&bSearch");
@ -46,6 +49,16 @@ public final class ChestMenuUtils {
return UI_BACKGROUND;
}
@Nonnull
public static ItemStack getNoPermissionItem() {
return NO_PERMISSION;
}
@Nonnull
public static ItemStack getNotResearchedItem() {
return NOT_RESEARCHED;
}
@Nonnull
public static ItemStack getInputSlotTexture() {
return INPUT_SLOT;

View File

@ -4,6 +4,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import io.github.thebusybiscuit.slimefun4.utils.tags.SlimefunTag;
@ -25,10 +28,12 @@ public final class ColoredMaterials {
*/
private ColoredMaterials() {}
// @formatter:off (We want this to stay formatted like this)
/**
* This {@link List} contains all wool colors ordered by their appearance ingame.
*/
public static final List<Material> WOOL = Collections.unmodifiableList(Arrays.asList(
public static final List<Material> WOOL = asList(new Material[] {
Material.WHITE_WOOL,
Material.ORANGE_WOOL,
Material.MAGENTA_WOOL,
@ -45,12 +50,12 @@ public final class ColoredMaterials {
Material.GREEN_WOOL,
Material.RED_WOOL,
Material.BLACK_WOOL
));
});
/**
* This {@link List} contains all stained glass colors ordered by their appearance ingame.
*/
public static final List<Material> STAINED_GLASS = Collections.unmodifiableList(Arrays.asList(
public static final List<Material> STAINED_GLASS = asList(new Material[] {
Material.WHITE_STAINED_GLASS,
Material.ORANGE_STAINED_GLASS,
Material.MAGENTA_STAINED_GLASS,
@ -67,12 +72,12 @@ public final class ColoredMaterials {
Material.GREEN_STAINED_GLASS,
Material.RED_STAINED_GLASS,
Material.BLACK_STAINED_GLASS
));
});
/**
* This {@link List} contains all stained glass pane colors ordered by their appearance ingame.
*/
public static final List<Material> STAINED_GLASS_PANE = Collections.unmodifiableList(Arrays.asList(
public static final List<Material> STAINED_GLASS_PANE = asList(new Material[] {
Material.WHITE_STAINED_GLASS_PANE,
Material.ORANGE_STAINED_GLASS_PANE,
Material.MAGENTA_STAINED_GLASS_PANE,
@ -89,12 +94,12 @@ public final class ColoredMaterials {
Material.GREEN_STAINED_GLASS_PANE,
Material.RED_STAINED_GLASS_PANE,
Material.BLACK_STAINED_GLASS_PANE
));
});
/**
* This {@link List} contains all terracotta colors ordered by their appearance ingame.
*/
public static final List<Material> TERRACOTTA = Collections.unmodifiableList(Arrays.asList(
public static final List<Material> TERRACOTTA = asList(new Material[] {
Material.WHITE_TERRACOTTA,
Material.ORANGE_TERRACOTTA,
Material.MAGENTA_TERRACOTTA,
@ -111,12 +116,12 @@ public final class ColoredMaterials {
Material.GREEN_TERRACOTTA,
Material.RED_TERRACOTTA,
Material.BLACK_TERRACOTTA
));
});
/**
* This {@link List} contains all glazed terracotta colors ordered by their appearance ingame.
*/
public static final List<Material> GLAZED_TERRACOTTA = Collections.unmodifiableList(Arrays.asList(
public static final List<Material> GLAZED_TERRACOTTA = asList(new Material[] {
Material.WHITE_GLAZED_TERRACOTTA,
Material.ORANGE_GLAZED_TERRACOTTA,
Material.MAGENTA_GLAZED_TERRACOTTA,
@ -133,12 +138,12 @@ public final class ColoredMaterials {
Material.GREEN_GLAZED_TERRACOTTA,
Material.RED_GLAZED_TERRACOTTA,
Material.BLACK_GLAZED_TERRACOTTA
));
});
/**
* This {@link List} contains all concrete colors ordered by their appearance ingame.
*/
public static final List<Material> CONCRETE = Collections.unmodifiableList(Arrays.asList(
public static final List<Material> CONCRETE = asList(new Material[] {
Material.WHITE_CONCRETE,
Material.ORANGE_CONCRETE,
Material.MAGENTA_CONCRETE,
@ -155,6 +160,16 @@ public final class ColoredMaterials {
Material.GREEN_CONCRETE,
Material.RED_CONCRETE,
Material.BLACK_CONCRETE
));
});
// @formatter:on
@Nonnull
private static List<Material> asList(@Nonnull Material[] materials) {
Validate.noNullElements(materials, "The List cannot contain any null elements");
Validate.isTrue(materials.length == 16, "Expected 16, received: " + materials.length + ". Did you miss a color?");
return Collections.unmodifiableList(Arrays.asList(materials));
}
}

View File

@ -108,7 +108,8 @@ public enum HeadTexture {
CARGO_ARROW_RIGHT("c2f910c47da042e4aa28af6cc81cf48ac6caf37dab35f88db993accb9dfe516"),
ADD_NEW_LANGUAGE("3edd20be93520949e6ce789dc4f43efaeb28c717ee6bfcbbe02780142f716"),
IRON_GOLEM("89091d79ea0f59ef7ef94d7bba6e5f17f2f7d4572c44f90f76c4819a714"),
PIGLIN_HEAD("2882af1294a74023e6919a31d1a027310f2e142afb4667d230d155e7f21dbb41");
PIGLIN_HEAD("2882af1294a74023e6919a31d1a027310f2e142afb4667d230d155e7f21dbb41"),
NECROTIC_SKULL("7953b6c68448e7e6b6bf8fb273d7203acd8e1be19e81481ead51f45de59a8");
public static final HeadTexture[] valuesCache = values();

View File

@ -1,6 +1,7 @@
package io.github.thebusybiscuit.slimefun4.utils;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.time.Duration;
import java.time.LocalDateTime;
@ -12,16 +13,51 @@ import javax.annotation.Nullable;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
/**
* This class contains various utilities related to numbers and number formatting.
*
* @author TheBusyBiscuit
* @author Walshy
*
*/
public final class NumberUtils {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##");
/**
* This is our {@link DecimalFormat} for decimal values.
*/
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("#.##", DecimalFormatSymbols.getInstance(Locale.ROOT));
/**
* We do not want any instance of this to be created.
*/
private NumberUtils() {}
public static String formatBigNumber(int i) {
return NumberFormat.getNumberInstance(Locale.US).format(i);
/**
* This method formats a given {@link Integer} to be displayed nicely with
* decimal digit grouping.
* {@code 1000000} for example will return {@code "1,000,000"} as a {@link String}.
* It uses the american (US) {@link Locale} for this transformation.
*
* @param number
* Your {@link Integer}
*
* @return The formatted String
*/
@Nonnull
public static String formatBigNumber(int number) {
return NumberFormat.getNumberInstance(Locale.US).format(number);
}
/**
* This method transforms a String representation of a {@link LocalDateTime}
* from GitHub's API back into a {@link LocalDateTime} object
*
* @param date
* The formatted String version of a date from GitHub
*
* @return The {@link LocalDateTime} for the given input
*/
@Nonnull
public static LocalDateTime parseGitHubDate(@Nonnull String date) {
Validate.notNull(date, "Provided date was null");
return LocalDateTime.parse(date.substring(0, date.length() - 1));
@ -37,6 +73,7 @@ public final class NumberUtils {
*
* @return A representative {@link ChatColor}
*/
@Nonnull
public static ChatColor getColorFromPercentage(float percentage) {
if (percentage < 16.0F) {
return ChatColor.DARK_RED;
@ -53,13 +90,51 @@ public final class NumberUtils {
}
}
/**
* This returns the elapsed time since the given {@link LocalDateTime}.
* The output will be nicely formatted based on the elapsed hours or days since the
* given {@link LocalDateTime}.
*
* If a {@link LocalDateTime} from yesterday was passed it will return {@code "1d"}.
* One hour later it will read {@code "1d 1h"}. For values smaller than an hour {@code "< 1h"}
* will be returned instead.
*
* @param date
* The {@link LocalDateTime}.
*
* @return The elapsed time as a {@link String}
*/
@Nonnull
public static String getElapsedTime(@Nonnull LocalDateTime date) {
Validate.notNull(date, "Provided date was null");
long hours = Duration.between(date, LocalDateTime.now()).toHours();
return getElapsedTime(LocalDateTime.now(), date);
}
/**
* This returns the elapsed time between the two given {@link LocalDateTime LocalDateTimes}.
* The output will be nicely formatted based on the elapsed hours or days between the
* given {@link LocalDateTime LocalDateTime}.
*
* If a {@link LocalDateTime} from today and yesterday (exactly 24h apart) was passed it
* will return {@code "1d"}.
* One hour later it will read {@code "1d 1h"}. For values smaller than an hour {@code "< 1h"}
* will be returned instead.
*
* @param start
* The starting {@link LocalDateTime}.
* @param end
* The ending {@link LocalDateTime}.
*
* @return The elapsed time as a {@link String}
*/
@Nonnull
public static String getElapsedTime(@Nonnull LocalDateTime start, @Nonnull LocalDateTime end) {
Validate.notNull(start, "Provided start was null");
Validate.notNull(end, "Provided end was null");
long hours = Duration.between(start, end).toHours();
if (hours == 0) {
return "< 1h";
} else if ((hours / 24) == 0) {
} else if (hours / 24 == 0) {
return (hours % 24) + "h";
} else if (hours % 24 == 0) {
return (hours / 24) + "d";
@ -68,10 +143,12 @@ public final class NumberUtils {
}
}
@Nonnull
public static String getTimeLeft(int seconds) {
String timeleft = "";
int minutes = (int) (seconds / 60L);
if (minutes > 0) {
timeleft += minutes + "m ";
}
@ -80,14 +157,27 @@ public final class NumberUtils {
return timeleft + seconds + "s";
}
public static int getInt(String str, int defaultValue) {
/**
* This method parses a {@link String} into an {@link Integer}.
* If the {@link String} could not be parsed correctly, the provided
* default value will be returned instead.
*
* @param str
* The {@link String} to parse
* @param defaultValue
* The default value for when the {@link String} could not be parsed
*
* @return The resulting {@link Integer}
*/
public static int getInt(@Nonnull String str, int defaultValue) {
if (PatternUtils.NUMERIC.matcher(str).matches()) {
return Integer.parseInt(str);
}
} else {
return defaultValue;
}
}
@Nonnull
public static String getAsMillis(long nanoseconds) {
if (nanoseconds == 0) {
return "0ms";
@ -129,6 +219,8 @@ public final class NumberUtils {
* The value to clamp
* @param max
* The maximum value
*
* @return The clamped value
*/
public static int clamp(int min, int value, int max) {
if (value < min) {

View File

@ -121,7 +121,7 @@ public final class SlimefunUtils {
}
private static boolean hasSoulboundFlag(@Nullable ItemMeta meta) {
if (meta != null && SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
if (meta != null) {
PersistentDataContainer container = meta.getPersistentDataContainer();
if (container.has(SOULBOUND_KEY, PersistentDataType.BYTE)) {
@ -154,7 +154,6 @@ public final class SlimefunUtils {
boolean isSoulbound = isSoulbound(item);
ItemMeta meta = item.getItemMeta();
if (SlimefunPlugin.getMinecraftVersion().isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
PersistentDataContainer container = meta.getPersistentDataContainer();
if (makeSoulbound && !isSoulbound) {
@ -164,7 +163,6 @@ public final class SlimefunUtils {
if (!makeSoulbound && isSoulbound) {
container.remove(SOULBOUND_KEY);
}
}
List<String> lore = meta.hasLore() ? meta.getLore() : new ArrayList<>();

View File

@ -48,6 +48,11 @@ public enum SlimefunTag implements Tag<Material> {
*/
ORES,
/**
* All minecraft ores that can be affected by fortune.
*/
FORTUNE_COMPATIBLE_ORES,
/**
* All Shulker boxes, normal and colored.
*/
@ -63,6 +68,11 @@ public enum SlimefunTag implements Tag<Material> {
*/
MUSHROOMS,
/**
* All leather armor materials
*/
LEATHER_ARMOR,
/**
* Every glass variant, includes both blocks and panes.
* Also stained glass and stained glass panes.
@ -99,12 +109,28 @@ public enum SlimefunTag implements Tag<Material> {
*/
STONE_VARIANTS,
/**
* All dirt variants. Dirt, coarse dirt, grass, mycelium.
* This also includes farmland and grass paths.
*/
DIRT_VARIANTS,
/**
* All variants of concrete powder.
* Can you believe there is no tag for this already?
*/
CONCRETE_POWDERS,
/**
* All the types of pressure plates.
*/
PRESSURE_PLATES,
/**
* All tall flowers because minecraft doesn't have a tag for this
*/
TALL_FLOWERS,
/**
* Materials which are sensitive to break.
* Things like Saplings or Pressure plates which break as well when you break

View File

@ -134,6 +134,7 @@ public class Category implements Keyed {
*
* @param p
* The Player to create this {@link ItemStack} for
*
* @return A localized display item for this {@link Category}
*/
@Nonnull
@ -166,6 +167,26 @@ public class Category implements Keyed {
return ChatColor.stripColor(item.getItemMeta().getDisplayName());
}
/**
* This returns the localized display name of this {@link Category} 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}
*/
@Nonnull
public String getDisplayName(@Nonnull Player p) {
String localized = SlimefunPlugin.getLocalization().getCategoryName(p, getKey());
if (localized != null) {
return localized;
} else {
return getUnlocalizedName();
}
}
/**
* Returns all instances of {@link SlimefunItem} bound to this {@link Category}.
*

View File

@ -5,9 +5,12 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
@ -238,20 +241,17 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
BlockMenu inv = BlockStorage.getInventory(b);
if (isProcessing(b)) {
if (takeCharge(b.getLocation())) {
int timeleft = progress.get(b);
if (timeleft > 0) {
ChestMenuUtils.updateProgressbar(inv, 22, timeleft, processing.get(b).getTicks(), getProgressBar());
if (isChargeable()) {
if (getCharge(b.getLocation()) < getEnergyConsumption()) {
return;
}
removeCharge(b.getLocation(), getEnergyConsumption());
}
progress.put(b, timeleft - 1);
} else {
inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
for (ItemStack output : processing.get(b).getOutput()) {
@ -263,6 +263,8 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
progress.remove(b);
processing.remove(b);
}
}
} else {
MachineRecipe next = findNextRecipe(inv);
@ -273,6 +275,26 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
}
}
/**
* This method will remove charge from a location if it is chargeable.
*
* @param l
* location to try to remove charge from
* @return Whether charge was taken if its chargeable
*/
protected boolean takeCharge(@Nonnull Location l) {
Validate.notNull(l, "Can't attempt to take charge from a null location!");
if (isChargeable()) {
if (getCharge(l) < getEnergyConsumption()) {
return false;
}
removeCharge(l, getEnergyConsumption());
}
return true;
}
protected MachineRecipe findNextRecipe(BlockMenu inv) {
Map<Integer, ItemStack> inventory = new HashMap<>();

View File

@ -19,7 +19,7 @@ import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow;
* @deprecated This interface is not designed to be used by addons.
*
*/
@Deprecated
// @Deprecated - commented out because we are not ready to send out warnings yet
public interface InventoryBlock {
/**

View File

@ -40,7 +40,6 @@ networks:
items:
talismans: true
backpacks: true
soulbound: true
metrics:

View File

@ -23,3 +23,4 @@ slimefun:
easter: חג הפסחא (אפריל)
birthday: יום הולדתו של TheBusyBiscuit (26 באוקטובר)
halloween: ליל כל הקדושים (31 באוקטובר)
androids: רובוטים ניתנים לתכנות

View File

@ -265,6 +265,7 @@ machines:
anvil:
not-working: '&4You cannot use Slimefun items in an anvil!'
mcmmo-salvaging: '&4You cannot salvage Slimefun items!'
brewing_stand:
not-working: '&4You cannot use Slimefun items in a brewing stand!'
@ -282,6 +283,9 @@ backpack:
workbench:
not-enhanced: '&4You cannot use Slimefun items in a normal workbench'
cauldron:
no-discoloring: '&4You cannot discolor Slimefun Armor'
gps:
deathpoint: '&4Deathpoint &7%date%'
waypoint:

View File

@ -255,6 +255,7 @@ machines:
anvil:
not-working: "&4Vous ne pouvez pas utiliser des objets Slimefun dans une enclume
!"
mcmmo-salvaging: "&4Vous ne pouvez pas recycler des objets Slimefun !"
backpack:
already-open: "&cDésolé, ce Backpack est ouvert quelque part ailleurs !"
no-stack: "&cVous ne pouvez pas stack les Backpacks"
@ -340,6 +341,7 @@ languages:
zh-CN: Chinois (Chine)
el: Grec
he: Hébreu
pt: Portugais (Portugal)
ar: Arabe
af: Afrikaans
da: Danois
@ -351,7 +353,6 @@ languages:
fa: Persan
th: Thaï
ro: Roumain
pt: Portugais (Portugal)
pt-BR: Portugais (Brésil)
bg: Bulgare
ko: Coréen
@ -369,5 +370,7 @@ villagers:
cartography_table:
not-working: "&4Vous ne pouvez pas utiliser d'objets Slimefun dans une table de
cartographie !"
cauldron:
no-discoloring: "&4Vous ne pouvez pas décolorer une armure Slimefun"
miner:
no-ores: "&eDésolé, je n'ai pas pu trouver de minerai à proximité !"

View File

@ -244,6 +244,7 @@ machines:
finished: Az Industrial Miner-ed kész! Összesen %ores% ércet szerzett!
anvil:
not-working: "&4Nem használhatsz Slimefun tárgyakat az üllőben!"
mcmmo-salvaging: "&4Nem hasznosíthatsz újra Slimefun tárgyakat!"
backpack:
already-open: "&cSajnáljuk, ez a hátizsák valahol máshol már nyitva van!"
no-stack: "&cNem halmozhatsz hátizsákokat"
@ -306,7 +307,7 @@ android:
rating:
own: "&4Nem értékelheted a saját szkriptedet!"
already: "&4Ezt a szkriptet már értékelted!"
editor: Szkript Szerkesztő
editor: Szkript szerkesztő
languages:
default: Szerver-alapértelmezett
en: Angol
@ -328,7 +329,6 @@ languages:
zh-CN: Kínai (Kína)
el: Görög
he: Héber
pt-BR: Portugál (Brazília)
ar: Arab
af: Afrikaans
da: Dán
@ -341,6 +341,7 @@ languages:
th: Thai
ro: Román
pt: Portugál (Portugália)
pt-BR: Portugál (Brazília)
bg: Bolgár
ko: Koreai
tr: Török
@ -355,5 +356,7 @@ villagers:
no-trading: "&4Nem cserélhetsz Slimefun tárgyakat falusiakkal!"
cartography_table:
not-working: "&4Nem használhatsz Slimefun tárgyakat térképasztalban."
cauldron:
no-discoloring: "&4Nem színteleníthetsz Slimefun páncélt!"
miner:
no-ores: "&eSajnálom, nem találtam semmilyen ércet a közelben!"

View File

@ -228,6 +228,7 @@ machines:
finished: "&eIndustrial Minerの稼働完了合計で%ores%個の鉱石を入手しました!"
anvil:
not-working: "&4Slimefunアイテムは金床を利用できません"
mcmmo-salvaging: "&4Slimefunアイテムはサルベージできません"
backpack:
already-open: "&cこのバックパックはどこかで使用中です"
no-stack: "&cバックパックはスタックされていると使用できません"
@ -312,7 +313,6 @@ languages:
el: ギリシャ語
he: ヘブライ語
pt: ポルトガル語(ポルトガル)
pt-BR: ポルトガル語(ブラジル)
ar: アラビア語
af: アフリカーンス語
da: デンマーク語
@ -324,6 +324,7 @@ languages:
fa: ペルシア語
th: タイ語
ro: ルーマニア語
pt-BR: ポルトガル語(ブラジル)
bg: ブルガリア語
ko: 韓国語
tr: トルコ語
@ -338,5 +339,7 @@ villagers:
no-trading: "&4Slimefunアイテムは村人との取引に使用できません"
cartography_table:
not-working: "&4Slimefunアイテムは製図台を使用できません"
cauldron:
no-discoloring: "&4Slimefunアイテムの脱色はできません"
miner:
no-ores: "&e周辺には鉱石が見つかりませんでした"

View File

@ -20,6 +20,10 @@ commands:
player-never-joined: "&4Игрок с таким ником не найден!"
backpack-does-not-exist: "&4Указанный рюкзак не существует!"
restored-backpack-given: "&aРюкзак был восстановлен и добавлен в Ваш инвентарь!"
charge:
description: Заряжает предмет, который Вы держите
charge-success: Предмет заряжен!
not-rechargeable: Этот предмет не может быть заряжен!
guide:
search:
message: "&bЧто бы Вы хотели найти?"
@ -83,6 +87,7 @@ guide:
miner: Ресурсы, добываемые этим шахтёром
generator: Доступные виды топлива
gold-pan: Ресурсы, которые Вы можете получить
climbing-pick: Поверхности для карабканья
back:
title: Назад
guide: Вернуться к руководству Slimefun
@ -129,6 +134,7 @@ messages:
whirlwind: "&a&oВаш талисман отразил снаряд"
wizard: "&a&oТалисман повысил уровень зачарования «Удача», но мог также ухудшить
другие зачарования"
caveman: "&a&oВаш талисман выдал Вам «Спешку»"
soulbound-rune:
fail: "&cВы можете привязать к себе только один предмет за раз."
success: "&aВы успешно привязали этот предмет к себе! Он останется при Вас после
@ -177,6 +183,10 @@ messages:
multi-tool:
mode-change: "&bРежим «%device%» изменён на: &9%mode%"
not-shears: "&cМультиинструмент не может быть использован в качестве ножниц!"
climbing-pick:
dual-wielding: "&4Вы должны держать кирку для скалолазания в обеих руках!"
wrong-material: "&cВы не можете карабкаться по этой поверхности. Проверьте руководство
Slimefun для большей информации!"
mode-change: "&b%device% | Режим изменён на: &9%mode%"
machines:
pattern-not-found: "&eК сожалению, не удалось распознать этот рецепт. Пожалуйста,
@ -320,6 +330,7 @@ languages:
zh-CN: Китайский (Китай)
el: Греческий
he: Иврит
pt: Португальский (Португалия)
pt-BR: Португальский (Бразилия)
ar: Арабский
af: Бурский
@ -332,7 +343,6 @@ languages:
fa: Персидский
th: Тайский
ro: Румынский
pt: Португальский (Португалия)
bg: Болгарский
ko: Корейский
tr: Турецкий
@ -345,5 +355,7 @@ brewing_stand:
not-working: "&4Вы не можете использовать Slimefun предметы в варочной стойке!"
villagers:
no-trading: "&4Вы не можете торговаться с крестьянами Slimefun предметами!"
cartography_table:
not-working: "&4Вы не можете использовать Slimefun предметы в столе картографа!"
miner:
no-ores: "&eК сожалению, не удалось найти какую-либо руду поблизости!"

View File

@ -21,6 +21,10 @@ commands:
backpack-does-not-exist: "&4Ang tinukoy na backpack ay hindi umiiral!"
restored-backpack-given: "&aAng iyong backpack ay naibalik at naidagdag sa iyong
imbentaryo!"
charge:
description: I-chacharge ang item ng iyong hinahawakan.
charge-success: Na-charge na ang item!
not-rechargeable: Hindi puedeng i-charge ang item na ito.
guide:
search:
message: "&bAno ang hinahanap mo?"
@ -53,6 +57,7 @@ guide:
addons: Ang mga Addons para sa Slimefun4
bugs: Mga Bug Reports
source: Ang Source Code
versions: Mga na-install na versions
credits:
commit: Commit
commits: Mga Commits
@ -62,6 +67,12 @@ guide:
resourcepack: "&cResourcepack Artist"
translator: "&9Translator"
profile-link: I-click ito upang bisitahin ang kanilang profile sa GitHub.
open: Pindutin ito upang makita ang aming mga nag-ambag
description:
- "&7Ang Slimefun ay isang proyekto na bukas na mapagkukunan"
- "&7at pinapanatili ng isang malaking pamayanan ng mga tao."
- "&7Mga hanggang &e%contributors% &7na mga tao ang tumutulong sa"
- "&7Slimefun sa buong lahat ng mga taong ito."
pages:
previous: Nakaraang pahina.
next: Susunod na pahina.
@ -74,6 +85,7 @@ guide:
miner: Mga mapagkukunan na maaari mong makuha sa Miner na ito.
generator: Magagamit na mga uri ng gasolina.
gold-pan: Mga mapagkukunan na maaari mong makuha.
climbing-pick: Mga ibabaw na maaari mong akyatin
back:
title: Balik
guide: Bumalik sa Slimefun Guide
@ -175,6 +187,11 @@ messages:
multi-tool:
mode-change: "&b%device% napalitan ang mode sa: &9%mode%"
not-shears: "&cBawal gamitin ang Multi-Tool bilang shears!"
climbing-pick:
dual-wielding: "&4Kailangan mong hawakan ang Climbing Picks ng dalawang kamay
upang magamit ito!"
wrong-material: "&cHindi ka maaaring umakyat sa ibabaw na ito. Suriin ang iyong
Slimefun Guide para sa karagdagang impormasyon!"
mode-change: "&b%device% mode ay pinalitan ng: &9%mode%"
machines:
pattern-not-found: "&ePasensiya na, hindi ko maintindihan ang Recipe na ito. Pakilagay
@ -239,6 +256,7 @@ machines:
%ores% ore(s)!"
anvil:
not-working: "&4Hindi puwedeng gamitin ang mga Slimefun Aytem sa isang Anvil!"
mcmmo-salvaging: "&4Bawal i-salvage ang mga Slimefun items!"
backpack:
already-open: "&cSorry, ang backpack na ito ay nakabukas na sa ibang lugar!"
no-stack: "&cHindi puwedeng i-stack ang mga Backpack."
@ -349,3 +367,7 @@ brewing_stand:
not-working: "&4Hindi ka maaaring gumamit ng mga Item ng Slimefun sa Brewing Stand!"
villagers:
no-trading: "&4Hindi ka maaaring mag-trade ng mga Slimefun Items sa mga villagers!"
cartography_table:
not-working: "&4Hindi mo puedeng gamitin ang mga Slimefun items sa cartography table!"
cauldron:
no-discoloring: "&4Hindi mo puedeng i-discolor ang Slimefun Armor."

View File

@ -20,6 +20,10 @@ commands:
player-never-joined: "&4找不到叫这个名字的玩家!"
backpack-does-not-exist: "&4你指定的背包不存在!"
restored-backpack-given: "&a你的背包已被恢复并且已经放入了你的物品栏!"
charge:
description: 为你手持的物品充电
charge-success: 充电完成!
not-rechargeable: 这个物品不能充电!
guide:
search:
message: "&b你想要搜索什么?"
@ -127,6 +131,7 @@ messages:
knight: "&a&o你的护身符给予了你 5 秒的生命恢复"
whirlwind: "&a&o你的护身符反弹了所有的弹射物"
wizard: "&a&o你的护身符使一个附魔的等级提高了, 同时其他附魔等级将会下降"
caveman: "&a&o你的护身符给予了你急迫效果"
soulbound-rune:
fail: "&c一次只能灵魂绑定一个物品."
success: "&a物品绑定成功! 在你死亡后此物品将不会掉落."
@ -223,6 +228,7 @@ machines:
finished: "&e你的工业矿机采矿已完成! 总共开采了 %ores% 个矿石!"
anvil:
not-working: "&4你不能在铁砧里使用 Slimefun 的物品"
mcmmo-salvaging: "&4你不能分解 Slimefun 物品!"
backpack:
already-open: "&c抱歉, 这个背包已在别处打开了!"
no-stack: "&c你不能同时手持两个背包"
@ -331,5 +337,9 @@ brewing_stand:
not-working: "&4你不能在酿造台中使用 Slimefun 物品!"
villagers:
no-trading: "&4你不能用 Slimefun 的物品和村民交易!"
cartography_table:
not-working: "&4你不能在制图台中使用 Slimefun 物品!"
cauldron:
no-discoloring: "&4你不能用炼药锅清洗 Slimefun 物品上的颜色"
miner:
no-ores: "&e抱歉, 周围找不到矿石了!"

View File

@ -246,3 +246,4 @@ slimefun:
caveman_talisman: Az Ősember talizmánja
even_higher_tier_capacitors: 3. szintű kondenzátorok
elytra_cap: Ütközésvédelem
energy_connectors: Vezetékes csatlakozás

View File

@ -246,3 +246,4 @@ slimefun:
caveman_talisman: 洞窟暮らしのタリスマン
even_higher_tier_capacitors: キャパシタⅢ
elytra_cap: 衝撃緩和装備
energy_connectors: 有線接続

View File

@ -240,3 +240,10 @@ slimefun:
lead_clothing: Свинцовое обмундирование
tape_measure: Рулетка
iron_golem_assembler: Образователь железных големов
climbing_pick: Покоритель поверхностей
shulker_shell: Синтетические шалкеры
villager_rune: Сбрасывание торговли
caveman_talisman: Талисман шахтёра
even_higher_tier_capacitors: Большой накопитель энергии
elytra_cap: Противоударная экипировка
energy_connectors: Проводные соединения

View File

@ -240,3 +240,10 @@ slimefun:
lead_clothing: Lead Clothing
tape_measure: Tape Measure
iron_golem_assembler: Automated Iron Golems
climbing_pick: Block Raider
shulker_shell: Synthetic Shulkers
villager_rune: Reset Villager Trades
caveman_talisman: Talisman of the Caveman
even_higher_tier_capacitors: Tier 3 Capacitors
elytra_cap: Crash Gear
energy_connectors: Wired Connections

View File

@ -246,3 +246,4 @@ slimefun:
caveman_talisman: Mağara Adamı Tılsımı
even_higher_tier_capacitors: Seviye 3 Kapasitörler
elytra_cap: İniş Takımı
energy_connectors: Kablolu Bağlantı

View File

@ -243,3 +243,6 @@ slimefun:
climbing_pick: 古块丽影
shulker_shell: 人造潜影贝
villager_rune: 防奸商神器
caveman_talisman: 穴居人护身符
even_higher_tier_capacitors: 三级电容器
energy_connectors: 有线连接

View File

@ -5,9 +5,9 @@ description: Slimefun basically turns your entire Server into a FTB modpack with
website: https://github.com/Slimefun
main: io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin
softdepend: [CS-CoreLib, PlaceholderAPI, WorldEdit, EmeraldEnchants]
softdepend: [CS-CoreLib, PlaceholderAPI, WorldEdit, EmeraldEnchants, mcMMO]
api-version: '1.13'
api-version: '1.14'
commands:
slimefun:

View File

@ -1,24 +1,62 @@
{
"values" : [
"#slimefun:sensitive_materials",
"#slimefun:tall_flowers",
"#slimefun:mushrooms",
{
"id" : "#minecraft:tall_flowers",
"required" : false
},
{
"id" : "#minecraft:beds",
"required" : false
},
{
"id" : "#minecraft:doors",
"required" : false
},
"#minecraft:beds",
"#minecraft:buttons",
"#minecraft:signs",
"#minecraft:doors",
"#minecraft:rails",
"#minecraft:small_flowers",
"#minecraft:coral_blocks",
"#minecraft:corals",
"#minecraft:carpets",
"#minecraft:banners",
"minecraft:sugar_cane",
"minecraft:cactus",
"minecraft:bamboo",
"minecraft:vine",
"minecraft:ladder",
"minecraft:chorus_plant",
"minecraft:chorus_flower",
"minecraft:snow",
"minecraft:lever",
"minecraft:repeater",
"minecraft:tripwire_hook",
"minecraft:lily_pad",
"minecraft:dead_bush",
"minecraft:fern",
"minecraft:grass",
"minecraft:sea_pickle",
"minecraft:nether_wart",
"minecraft:seagrass",
"minecraft:tall_seagrass",
"minecraft:kelp",
"minecraft:bell",
"minecraft:lantern",
{
"id" : "minecraft:bamboo",
"id" : "minecraft:soul_lantern",
"required" : false
},
{
"id" : "minecraft:nether_sprouts",
"required" : false
},
{
"id" : "minecraft:crimson_roots",
"required": false
},
{
"id" : "minecraft:twisting_vines",
"required" : false
},
{
"id" : "minecraft:warped_roots",
"required" : false
},
{
"id" : "minecraft:weeping_vines",
"required" : false
}
]

View File

@ -12,9 +12,6 @@
"minecraft:pumpkin_stem",
"minecraft:nether_wart",
"minecraft:cocoa",
{
"id" : "minecraft:sweet_berry_bush",
"required" : false
}
"minecraft:sweet_berry_bush"
]
}

View File

@ -0,0 +1,11 @@
{
"values" : [
"minecraft:dirt",
"minecraft:coarse_dirt",
"minecraft:grass_block",
"minecraft:grass_path",
"minecraft:farmland",
"minecraft:podzol",
"minecraft:mycelium"
]
}

View File

@ -1,10 +1,8 @@
{
"values" : [
"#minecraft:sand",
"#minecraft:dirt_like",
"#slimefun:concrete_powders",
"minecraft:farmland",
"minecraft:grass_path",
"#slimefun:dirt_variants",
"minecraft:snow",
"minecraft:snow_block",
"minecraft:gravel",

View File

@ -0,0 +1,10 @@
{
"values" : [
"minecraft:coal_ore",
"minecraft:lapis_ore",
"minecraft:diamond_ore",
"minecraft:redstone_ore",
"minecraft:emerald_ore",
"minecraft:nether_quartz_ore"
]
}

View File

@ -0,0 +1,8 @@
{
"values" : [
"minecraft:leather_helmet",
"minecraft:leather_chestplate",
"minecraft:leather_leggings",
"minecraft:leather_boots"
]
}

View File

@ -6,11 +6,6 @@
},
"minecraft:gold_ore",
"minecraft:iron_ore",
"minecraft:coal_ore",
"minecraft:lapis_ore",
"minecraft:diamond_ore",
"minecraft:redstone_ore",
"minecraft:emerald_ore",
"minecraft:nether_quartz_ore"
"#slimefun:fortune_compatible_ores"
]
}

Some files were not shown because too many files have changed in this diff Show More