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

Merge pull request #3 from Slimefun/master

[CI skip] Update fork
This commit is contained in:
CURVX 2020-10-16 01:09:20 +05:30 committed by GitHub
commit adcb52becf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
108 changed files with 1658 additions and 663 deletions

View File

@ -2,7 +2,7 @@
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
**Table of contents**
- [Release Candidate 17 (TBD)](#release-candidate-17-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 +22,7 @@
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
## Release Candidate 17 (TBD)
## Release Candidate 17 (17 Oct 2020)
#### Additions
* Added /sf charge
@ -39,6 +39,11 @@
* Added "slimefun.gps.bypass" permission to open GPS devices anywhere
* (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)
@ -80,6 +85,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

32
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>
@ -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.149</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

@ -81,7 +81,7 @@ public class ErrorReport<T extends Throwable> {
}
stream.println("Slimefun Data:");
stream.println(" ID: " + item.getID());
stream.println(" ID: " + item.getId());
stream.println(" Inventory: " + BlockStorage.getStorage(l.getWorld()).hasInventory(l));
stream.println(" Data: " + BlockStorage.getBlockInfoAsJson(l));
stream.println();
@ -92,7 +92,7 @@ public class ErrorReport<T extends Throwable> {
public ErrorReport(T throwable, SlimefunItem item) {
this(throwable, item.getAddon(), stream -> {
stream.println("SlimefunItem:");
stream.println(" ID: " + item.getID());
stream.println(" ID: " + item.getId());
stream.println(" Plugin: " + (item.getAddon() == null ? "Unknown" : item.getAddon().getName()));
stream.println();
});

View File

@ -102,7 +102,7 @@ public final class HashedArmorpiece {
@Override
public String toString() {
return "HashedArmorpiece {hash=" + hash + ",item=" + item.map(SlimefunItem::getID).orElse("null") + '}';
return "HashedArmorpiece {hash=" + hash + ",item=" + item.map(SlimefunItem::getId).orElse("null") + '}';
}
}

View File

@ -139,15 +139,15 @@ public class ItemSetting<T> {
*/
@SuppressWarnings("unchecked")
public void load(@Nonnull SlimefunItem item) {
SlimefunPlugin.getItemCfg().setDefaultValue(item.getID() + '.' + getKey(), getDefaultValue());
Object configuredValue = SlimefunPlugin.getItemCfg().getValue(item.getID() + '.' + getKey());
SlimefunPlugin.getItemCfg().setDefaultValue(item.getId() + '.' + getKey(), getDefaultValue());
Object configuredValue = SlimefunPlugin.getItemCfg().getValue(item.getId() + '.' + getKey());
if (defaultValue.getClass().isInstance(configuredValue)) {
if (validateInput((T) configuredValue)) {
this.value = (T) configuredValue;
} else {
Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getID(), getKey() });
Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
Slimefun.getLogger().log(Level.WARNING, "{0} is not a valid input!", configuredValue);
Slimefun.getLogger().log(Level.WARNING, getErrorMessage());
}
@ -157,7 +157,7 @@ public class ItemSetting<T> {
Slimefun.getLogger().log(Level.WARNING, "Slimefun has found an invalid config setting in your Items.yml!");
Slimefun.getLogger().log(Level.WARNING, "Please only use settings that are valid.");
Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getID(), getKey() });
Slimefun.getLogger().log(Level.WARNING, " at \"{0}.{1}\"", new Object[] { item.getId(), getKey() });
Slimefun.getLogger().log(Level.WARNING, "Expected \"{0}\" but found: \"{1}\"", new Object[] { defaultValue.getClass().getSimpleName(), found });
}
}

View File

@ -66,6 +66,12 @@ public interface EnergyNetComponent extends ItemAttribute {
*/
default int getCharge(@Nonnull Location l) {
Validate.notNull(l, "Location was null!");
// Emergency fallback, this cannot hold a charge, so we'll just return zero
if (!isChargeable()) {
return 0;
}
String charge = BlockStorage.getLocationInfo(l, "energy-charge");
if (charge != null) {

View File

@ -99,7 +99,7 @@ class SlimefunTabCompleter implements TabCompleter {
List<String> list = new ArrayList<>(items.size());
for (SlimefunItem item : items) {
list.add(item.getID());
list.add(item.getId());
}
return list;

View File

@ -119,7 +119,7 @@ public class MultiBlock {
@Override
public int hashCode() {
return Objects.hash(item.getID(), blocks, trigger, isSymmetric);
return Objects.hash(item.getId(), blocks, trigger, isSymmetric);
}
private boolean compareBlocks(Material a, @Nullable Material b) {
@ -161,6 +161,6 @@ public class MultiBlock {
@Override
public String toString() {
return "MultiBlock (" + item.getID() + ") {" + Arrays.toString(blocks) + "}";
return "MultiBlock (" + item.getId() + ") {" + Arrays.toString(blocks) + "}";
}
}

View File

@ -70,6 +70,7 @@ public class EnergyNet extends Network {
return null;
} else {
switch (component.getEnergyComponentType()) {
case CONNECTOR:
case CAPACITOR:
return NetworkComponent.CONNECTOR;
case CONSUMER:
@ -272,6 +273,20 @@ public class EnergyNet extends Network {
return null;
}
/**
* This attempts to get an {@link EnergyNet} from a given {@link Location}.
* If no suitable {@link EnergyNet} could be found, {@code null} will be returned.
*
* @param l
* The target {@link Location}
*
* @return The {@link EnergyNet} at that {@link Location}, or {@code null}
*/
@Nullable
public static EnergyNet getNetworkFromLocation(@Nonnull Location l) {
return SlimefunPlugin.getNetworkManager().getNetworkFromLocation(l, EnergyNet.class).orElse(null);
}
/**
* This attempts to get an {@link EnergyNet} from a given {@link Location}.
* If no suitable {@link EnergyNet} could be found, a new one will be created.

View File

@ -4,6 +4,7 @@ import org.bukkit.block.Block;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors.Reactor;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
@ -13,6 +14,7 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AGenerator;
* can have.
*
* @author TheBusyBiscuit
* @author Linox
*
* @see EnergyNetComponent
* @see EnergyNet
@ -38,6 +40,12 @@ public enum EnergyNetComponentType {
*/
CONSUMER,
/**
* A Connector transmits energy through the network.
* Also see: {@link EnergyConnector}
*/
CONNECTOR,
/**
* A fallback value to use when a {@link Block} cannot be classified as any of the
* other options.

View File

@ -64,9 +64,9 @@ public class CustomTextureService {
for (SlimefunItem item : items) {
if (item != null) {
config.setDefaultValue(item.getID(), 0);
config.setDefaultValue(item.getId(), 0);
if (config.getInt(item.getID()) != 0) {
if (config.getInt(item.getId()) != 0) {
modified = true;
}
}

View File

@ -85,7 +85,7 @@ public class PerWorldSettingsService {
return false;
}
return !items.contains(item.getID());
return !items.contains(item.getId());
}
/**
@ -105,9 +105,9 @@ public class PerWorldSettingsService {
Set<String> items = disabledItems.computeIfAbsent(world.getUID(), id -> loadWorldFromConfig(world));
if (enabled) {
items.remove(item.getID());
items.remove(item.getId());
} else {
items.add(item.getID());
items.add(item.getId());
}
}
@ -178,7 +178,7 @@ public class PerWorldSettingsService {
for (SlimefunItem item : SlimefunPlugin.getRegistry().getEnabledSlimefunItems()) {
if (item != null) {
String addon = item.getAddon().getName().toLowerCase(Locale.ROOT);
config.setValue(addon + '.' + item.getID(), !items.contains(item.getID()));
config.setValue(addon + '.' + item.getId(), !items.contains(item.getId()));
}
}
@ -222,7 +222,7 @@ public class PerWorldSettingsService {
if (item != null) {
String addon = item.getAddon().getName().toLowerCase(Locale.ROOT);
config.setDefaultValue(addon + ".enabled", true);
config.setDefaultValue(addon + '.' + item.getID(), true);
config.setDefaultValue(addon + '.' + item.getId(), true);
// Whether the entire addon has been disabled
boolean isAddonDisabled = config.getBoolean(addon + ".enabled");
@ -232,8 +232,8 @@ public class PerWorldSettingsService {
blacklist.add(worldName);
}
if (!isAddonDisabled || !config.getBoolean(addon + '.' + item.getID())) {
items.add(item.getID());
if (!isAddonDisabled || !config.getBoolean(addon + '.' + item.getId())) {
items.add(item.getId());
}
}
}

View File

@ -41,12 +41,12 @@ public class PermissionsService {
public void register(@Nonnull Iterable<SlimefunItem> items, boolean save) {
for (SlimefunItem item : items) {
if (item != null) {
String path = item.getID() + ".permission";
String path = item.getId() + ".permission";
config.setDefaultValue(path, "none");
config.setDefaultValue(item.getID() + ".lore", new String[] { "&rYou do not have the permission", "&rto access this item." });
config.setDefaultValue(item.getId() + ".lore", new String[] { "&rYou do not have the permission", "&rto access this item." });
permissions.put(item.getID(), config.getString(path));
permissions.put(item.getId(), config.getString(path));
}
}
@ -72,7 +72,7 @@ public class PermissionsService {
return true;
}
String permission = permissions.get(item.getID());
String permission = permissions.get(item.getId());
return permission == null || permission.equals("none") || p.hasPermission(permission);
}
@ -89,7 +89,7 @@ public class PermissionsService {
@Nonnull
public Optional<String> getPermission(@Nonnull SlimefunItem item) {
Validate.notNull(item, "Cannot get permissions for null");
String permission = permissions.get(item.getID());
String permission = permissions.get(item.getId());
if (permission == null || permission.equals("none")) {
return Optional.empty();
@ -108,7 +108,7 @@ public class PermissionsService {
*/
public void setPermission(@Nonnull SlimefunItem item, @Nullable String permission) {
Validate.notNull(item, "You cannot set the permission for null");
permissions.put(item.getID(), permission != null ? permission : "none");
permissions.put(item.getId(), permission != null ? permission : "none");
}
/**
@ -124,7 +124,7 @@ public class PermissionsService {
@Nonnull
public List<String> getLore(@Nonnull SlimefunItem item) {
List<String> lore = config.getStringList(item.getID() + ".lore");
List<String> lore = config.getStringList(item.getId() + ".lore");
return lore == null ? Arrays.asList("LORE NOT FOUND") : lore;
}

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

@ -46,7 +46,7 @@ class ProfiledBlock {
}
public String getId() {
return item.getID();
return item.getId();
}
public SlimefunAddon getAddon() {

View File

@ -344,7 +344,7 @@ public class SlimefunProfiler {
public String getTime(@Nonnull SlimefunItem item) {
Validate.notNull("Cannot get timings for a null SlimefunItem");
long time = getByItem().getOrDefault(item.getID(), 0L);
long time = getByItem().getOrDefault(item.getId(), 0L);
return NumberUtils.getAsMillis(time);
}

View File

@ -672,12 +672,12 @@ public final class SlimefunItems {
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");
public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack("SMALL_CAPACITOR", HeadTexture.CAPACITOR_25, "&aSmall Energy Capacitor", "", LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7128 J Capacity");
public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack("MEDIUM_CAPACITOR", HeadTexture.CAPACITOR_25, "&aMedium Energy Capacitor", "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7512 J Capacity");
public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack("BIG_CAPACITOR", HeadTexture.CAPACITOR_25, "&aBig Energy Capacitor", "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &71024 J Capacity");
public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack("LARGE_CAPACITOR", HeadTexture.CAPACITOR_25, "&aLarge Energy Capacitor", "", LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &78192 J Capacity");
public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aCarbonado Edged Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &765536 J Capacity");
public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aEnergized Energy Capacitor", "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7524288 J Capacity");
public static final SlimefunItemStack SMALL_CAPACITOR = new SlimefunItemStack("SMALL_CAPACITOR", HeadTexture.CAPACITOR_25, "&aSmall Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.BASIC, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7128 J Capacity");
public static final SlimefunItemStack MEDIUM_CAPACITOR = new SlimefunItemStack("MEDIUM_CAPACITOR", HeadTexture.CAPACITOR_25, "&aMedium Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.AVERAGE, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7512 J Capacity");
public static final SlimefunItemStack BIG_CAPACITOR = new SlimefunItemStack("BIG_CAPACITOR", HeadTexture.CAPACITOR_25, "&aBig Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.MEDIUM, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &71024 J Capacity");
public static final SlimefunItemStack LARGE_CAPACITOR = new SlimefunItemStack("LARGE_CAPACITOR", HeadTexture.CAPACITOR_25, "&aLarge Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.GOOD, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &78192 J Capacity");
public static final SlimefunItemStack CARBONADO_EDGED_CAPACITOR = new SlimefunItemStack("CARBONADO_EDGED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aCarbonado Edged Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &765536 J Capacity");
public static final SlimefunItemStack ENERGIZED_CAPACITOR = new SlimefunItemStack("ENERGIZED_CAPACITOR", HeadTexture.CAPACITOR_25, "&aEnergized Energy Capacitor", LoreBuilder.range(6), "", LoreBuilder.machine(MachineTier.END_GAME, MachineType.CAPACITOR), "&8\u21E8 &e\u26A1 &7524288 J Capacity");
/* Robots */
public static final SlimefunItemStack PROGRAMMABLE_ANDROID = new SlimefunItemStack("PROGRAMMABLE_ANDROID", HeadTexture.PROGRAMMABLE_ANDROID, "&cProgrammable Android &7(Normal)", "", "&8\u21E8 &7Function: None", "&8\u21E8 &7Fuel Efficiency: 1.0x");
@ -750,6 +750,7 @@ public final class SlimefunItems {
public static final SlimefunItemStack BLISTERING_INGOT_3 = new SlimefunItemStack("BLISTERING_INGOT_3", Material.GOLD_INGOT, "&6Blistering Ingot", "", LoreBuilder.radioactive(Radioactivity.VERY_HIGH), LoreBuilder.HAZMAT_SUIT_REQUIRED);
public static final SlimefunItemStack ENERGY_REGULATOR = new SlimefunItemStack("ENERGY_REGULATOR", HeadTexture.ENERGY_REGULATOR, "&6Energy Regulator", "", "&fCore Component of an Energy Network");
public static final SlimefunItemStack ENERGY_CONNECTOR = new SlimefunItemStack("ENERGY_CONNECTOR", HeadTexture.ENERGY_CONNECTOR, "&eEnergy Connector", LoreBuilder.range(6), "", "&fPlace this between machines", "&fand generators to connect them", "&fto your regulator.");
public static final SlimefunItemStack DEBUG_FISH = new SlimefunItemStack("DEBUG_FISH", Material.SALMON, "&3How much is the Fish?", "", "&eRight Click &fany Block to view it's BlockData", "&eLeft Click &fto break a Block", "&eShift + Left Click &fany Block to erase it's BlockData", "&eShift + Right Click &fto place a Placeholder Block");
public static final SlimefunItemStack NETHER_ICE = new SlimefunItemStack("NETHER_ICE", HeadTexture.NETHER_ICE, "&eNether Ice", "", LoreBuilder.radioactive(Radioactivity.MODERATE), LoreBuilder.HAZMAT_SUIT_REQUIRED);

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,15 @@ 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);
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_14)) {
new GrindstoneListener(this);
new CartographyTableListener(this);
}
if (minecraftVersion.isAtLeast(MinecraftVersion.MINECRAFT_1_15)) {
new BeeListener(this);

View File

@ -208,7 +208,7 @@ public class BookSlimefunGuide implements SlimefunGuideImplementation {
}
private void addSlimefunItem(Category category, int page, Player p, PlayerProfile profile, SlimefunItem item, List<ChatComponent> items) {
NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), item.getID().toLowerCase(Locale.ROOT));
NamespacedKey key = new NamespacedKey(SlimefunPlugin.instance(), item.getId().toLowerCase(Locale.ROOT));
if (!Slimefun.hasUnlocked(p, item, false) && item.getResearch() != null) {
Research research = item.getResearch();

View File

@ -53,7 +53,7 @@ public class AncientPedestal extends SimpleSlimefunItem<BlockDispenseHandler> {
public AncientPedestal(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
SlimefunItem.registerBlockHandler(getID(), (p, b, tool, reason) -> {
SlimefunItem.registerBlockHandler(getId(), (p, b, tool, reason) -> {
Optional<Item> entity = getPlacedItem(b);
if (entity.isPresent()) {

View File

@ -81,7 +81,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
texture = item.getSkullTexture().orElse(null);
registerDefaultFuelTypes();
new BlockMenuPreset(getID(), "Programmable Android") {
new BlockMenuPreset(getId(), "Programmable Android") {
@Override
public void init() {
@ -131,7 +131,7 @@ public class ProgrammableAndroid extends SlimefunItem implements InventoryBlock,
}
};
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
boolean allow = reason == UnregisterReason.PLAYER_BREAK && (BlockStorage.getLocationInfo(b.getLocation(), "owner").equals(p.getUniqueId().toString()) || p.hasPermission("slimefun.android.bypass"));
if (allow) {

View File

@ -153,7 +153,7 @@ public class BlockPlacer extends SlimefunItem {
block.setType(item.getType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, item.getType());
BlockStorage.store(block, sfItem.getID());
BlockStorage.store(block, sfItem.getId());
handler.onBlockPlacerPlace(e);
if (dispenser.getInventory().containsAtLeast(item, 2)) {
@ -168,7 +168,7 @@ public class BlockPlacer extends SlimefunItem {
block.setType(item.getType());
block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, item.getType());
BlockStorage.store(block, sfItem.getID());
BlockStorage.store(block, sfItem.getId());
if (dispenser.getInventory().containsAtLeast(item, 2)) {
dispenser.getInventory().removeItem(new CustomItem(item, 1));

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

@ -51,7 +51,7 @@ abstract class AbstractCargoNode extends SlimefunItem {
});
new BlockMenuPreset(getID(), ChatUtils.removeColorCodes(item.getItemMeta().getDisplayName())) {
new BlockMenuPreset(getId(), ChatUtils.removeColorCodes(item.getItemMeta().getDisplayName())) {
@Override
public void init() {

View File

@ -32,7 +32,7 @@ abstract class AbstractFilterNode extends AbstractCargoNode {
public AbstractFilterNode(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -1,5 +1,7 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.cargo;
import javax.annotation.Nonnull;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@ -18,9 +20,14 @@ public class CargoConnectorNode extends SimpleSlimefunItem<BlockUseHandler> {
super(category, item, recipeType, recipe, recipeOutput);
}
@Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
if (!e.getClickedBlock().isPresent()) {
return;
}
Player p = e.getPlayer();
Block b = e.getClickedBlock().get();

View File

@ -24,7 +24,7 @@ public class CargoManager extends SlimefunItem {
public CargoManager(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
registerBlockHandler(getID(), (p, b, tool, reason) -> {
registerBlockHandler(getId(), (p, b, tool, reason) -> {
SimpleHologram.remove(b);
return true;
});

View File

@ -35,7 +35,7 @@ public class ReactorAccessPort extends SlimefunItem {
public ReactorAccessPort(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getID(), "&2Reactor Access Port") {
new BlockMenuPreset(getId(), "&2Reactor Access Port") {
@Override
public void init() {
@ -94,7 +94,7 @@ public class ReactorAccessPort extends SlimefunItem {
}
};
registerBlockHandler(getID(), (p, b, tool, reason) -> {
registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

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

@ -0,0 +1,64 @@
package io.github.thebusybiscuit.slimefun4.implementation.items.electric;
import javax.annotation.Nonnull;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent;
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockUseHandler;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* This {@link EnergyNetComponent} is a connector for the {@link EnergyNet} networks.
* They work similar to {@link Capacitor capacitors}.
*
* @author Linox
*
* @see EnergyNet
* @see EnergyNetComponent
*
*/
public class EnergyConnector extends SimpleSlimefunItem<BlockUseHandler> implements EnergyNetComponent {
public EnergyConnector(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
super(category, item, recipeType, recipe, recipeOutput);
}
@Nonnull
@Override
public BlockUseHandler getItemHandler() {
return e -> {
if (!e.getClickedBlock().isPresent()) {
return;
}
Player p = e.getPlayer();
Block b = e.getClickedBlock().get();
if (EnergyNet.getNetworkFromLocation(b.getLocation()) != null) {
p.sendMessage(ChatColors.color("&7Connected: " + "&2\u2714"));
} else {
p.sendMessage(ChatColors.color("&7Connected: " + "&4\u2718"));
}
};
}
@Nonnull
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONNECTOR;
}
@Override
public int getCapacity() {
return 0;
}
}

View File

@ -34,7 +34,7 @@ public class EnergyRegulator extends SlimefunItem {
public EnergyRegulator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
SlimefunItem.registerBlockHandler(getID(), (p, b, stack, reason) -> {
SlimefunItem.registerBlockHandler(getId(), (p, b, stack, reason) -> {
SimpleHologram.remove(b);
return true;
});

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

@ -62,7 +62,7 @@ public abstract class AbstractEntityAssembler<T extends Entity> extends SimpleSl
public AbstractEntityAssembler(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getID(), item.getImmutableMeta().getDisplayName().orElse("Entity Assembler")) {
new BlockMenuPreset(getId(), item.getImmutableMeta().getDisplayName().orElse("Entity Assembler")) {
@Override
public void init() {
@ -117,7 +117,7 @@ public abstract class AbstractEntityAssembler<T extends Entity> extends SimpleSl
};
addItemHandler(onPlace());
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
if (reason == UnregisterReason.EXPLODE) {
return false;
}

View File

@ -28,7 +28,7 @@ public abstract class AbstractGrowthAccelerator extends SlimefunItem implements
createPreset(this, this::constructMenu);
registerBlockHandler(getID(), (p, b, tool, reason) -> {
registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -39,7 +39,7 @@ public class AutoBreeder extends SlimefunItem implements InventoryBlock, EnergyN
createPreset(this, this::constructMenu);
registerBlockHandler(getID(), (p, b, tool, reason) -> {
registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -52,7 +52,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
public AutomatedCraftingChamber(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getID(), "&6Automated Crafting Chamber") {
new BlockMenuPreset(getId(), "&6Automated Crafting Chamber") {
@Override
public void init() {
@ -120,7 +120,7 @@ public abstract class AutomatedCraftingChamber extends SlimefunItem implements I
};
addItemHandler(onPlace());
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -44,7 +44,7 @@ public abstract class ElectricSmeltery extends AContainer {
public ElectricSmeltery(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getID(), getItemName()) {
new BlockMenuPreset(getId(), getItemName()) {
@Override
public void init() {
@ -99,7 +99,7 @@ public abstract class ElectricSmeltery extends AContainer {
}
};
registerBlockHandler(getID(), (p, b, tool, reason) -> {
registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

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

@ -54,7 +54,7 @@ public class FluidPump extends SimpleSlimefunItem<BlockTicker> implements Invent
createPreset(this, this::constructMenu);
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -28,7 +28,7 @@ public abstract class HeatedPressureChamber extends AContainer {
public HeatedPressureChamber(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getID(), getItemName()) {
new BlockMenuPreset(getId(), getItemName()) {
@Override
public void init() {

View File

@ -38,7 +38,7 @@ public class XPCollector extends SlimefunItem implements InventoryBlock, EnergyN
createPreset(this, this::constructMenu);
addItemHandler(onPlace());
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -80,7 +80,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
public Reactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(getID(), getInventoryTitle()) {
new BlockMenuPreset(getId(), getInventoryTitle()) {
@Override
public void init() {
@ -107,7 +107,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
}
};
registerBlockHandler(getID(), (p, b, tool, reason) -> {
registerBlockHandler(getId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -41,7 +41,7 @@ public abstract class GEOMiner extends AContainer implements RecipeDisplayItem {
super(category, item, recipeType, recipe);
addItemHandler(onPlace());
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
SimpleHologram.remove(b);
BlockMenu inv = BlockStorage.getInventory(b);

View File

@ -34,7 +34,7 @@ public abstract class OilPump extends AContainer implements RecipeDisplayItem {
oil = SlimefunPlugin.getRegistry().getGEOResources().get(new NamespacedKey(SlimefunPlugin.instance(), "oil")).orElse(null);
new BlockMenuPreset(getID(), getInventoryTitle()) {
new BlockMenuPreset(getId(), getInventoryTitle()) {
@Override
public void init() {

View File

@ -87,7 +87,7 @@ public class ElevatorPlate extends SimpleSlimefunItem<BlockUseHandler> {
Block block = b.getWorld().getBlockAt(b.getX(), y, b.getZ());
if (block.getType() == getItem().getType() && BlockStorage.check(block, getID())) {
if (block.getType() == getItem().getType() && BlockStorage.check(block, getId())) {
floors.add(block);
}
}

View File

@ -28,7 +28,7 @@ public abstract class GPSTransmitter extends SimpleSlimefunItem<BlockTicker> imp
this.capacity = 4 << (2 * tier);
addItemHandler(onPlace());
registerBlockHandler(getID(), (p, b, stack, reason) -> {
registerBlockHandler(getId(), (p, b, stack, reason) -> {
UUID owner = UUID.fromString(BlockStorage.getLocationInfo(b.getLocation(), "owner"));
SlimefunPlugin.getGPSNetwork().updateTransmitter(b.getLocation(), owner, false);
return true;

View File

@ -75,7 +75,7 @@ public class Talisman extends SlimefunItem {
lore.add(line);
}
enderTalisman = new SlimefunItemStack("ENDER_" + getID(), getItem().getType(), name, lore.toArray(new String[0]));
enderTalisman = new SlimefunItemStack("ENDER_" + getId(), getItem().getType(), name, lore.toArray(new String[0]));
} else {
enderTalisman = null;
}
@ -108,7 +108,7 @@ public class Talisman extends SlimefunItem {
@Override
public void postRegister() {
EnderTalisman talisman = new EnderTalisman(this, getEnderVariant());
talisman.register(addon);
talisman.register(getAddon());
}
@Override

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

@ -45,7 +45,7 @@ public class ChristmasPresent extends SimpleSlimefunItem<BlockPlaceHandler> impl
e.setCancelled(true);
if (e.getPlayer().getGameMode() != GameMode.CREATIVE) {
ItemUtils.consumeItem(item, false);
ItemUtils.consumeItem(e.getItemInHand(), false);
}
FireworkUtils.launchRandom(e.getPlayer(), 3);

View File

@ -127,7 +127,7 @@ class ExplosiveTool extends SimpleSlimefunItem<ToolUseHandler> implements NotPla
SlimefunItem sfItem = BlockStorage.check(b);
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
SlimefunBlockHandler handler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
if (handler != null && !handler.onBreak(p, b, sfItem, UnregisterReason.PLAYER_BREAK)) {
drops.add(BlockStorage.retrieve(b));

View File

@ -104,12 +104,12 @@ public class AncientAltarListener implements Listener {
return;
}
String id = slimefunBlock.get().getID();
String id = slimefunBlock.get().getId();
if (id.equals(pedestalItem.getID())) {
if (id.equals(pedestalItem.getId())) {
e.cancel();
usePedestal(b, e.getPlayer());
} else if (id.equals(altarItem.getID())) {
} else if (id.equals(altarItem.getId())) {
if (!Slimefun.hasUnlocked(e.getPlayer(), altarItem, true) || altarsInUse.contains(b.getLocation())) {
e.cancel();
return;
@ -259,7 +259,7 @@ public class AncientAltarListener implements Listener {
if (pedestal.getType() == Material.DISPENSER) {
String id = BlockStorage.checkID(pedestal);
if (id != null && id.equals(pedestalItem.getID())) {
if (id != null && id.equals(pedestalItem.getId())) {
SlimefunPlugin.getLocalization().sendMessage(e.getPlayer(), "messages.cannot-place", true);
e.setCancelled(true);
}
@ -270,28 +270,28 @@ public class AncientAltarListener implements Listener {
private List<Block> getPedestals(@Nonnull Block altar) {
List<Block> list = new ArrayList<>();
if (BlockStorage.check(altar.getRelative(2, 0, -2), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(2, 0, -2), pedestalItem.getId())) {
list.add(altar.getRelative(2, 0, -2));
}
if (BlockStorage.check(altar.getRelative(3, 0, 0), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(3, 0, 0), pedestalItem.getId())) {
list.add(altar.getRelative(3, 0, 0));
}
if (BlockStorage.check(altar.getRelative(2, 0, 2), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(2, 0, 2), pedestalItem.getId())) {
list.add(altar.getRelative(2, 0, 2));
}
if (BlockStorage.check(altar.getRelative(0, 0, 3), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(0, 0, 3), pedestalItem.getId())) {
list.add(altar.getRelative(0, 0, 3));
}
if (BlockStorage.check(altar.getRelative(-2, 0, 2), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(-2, 0, 2), pedestalItem.getId())) {
list.add(altar.getRelative(-2, 0, 2));
}
if (BlockStorage.check(altar.getRelative(-3, 0, 0), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(-3, 0, 0), pedestalItem.getId())) {
list.add(altar.getRelative(-3, 0, 0));
}
if (BlockStorage.check(altar.getRelative(-2, 0, -2), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(-2, 0, -2), pedestalItem.getId())) {
list.add(altar.getRelative(-2, 0, -2));
}
if (BlockStorage.check(altar.getRelative(0, 0, -3), pedestalItem.getID())) {
if (BlockStorage.check(altar.getRelative(0, 0, -3), pedestalItem.getId())) {
list.add(altar.getRelative(0, 0, -3));
}

View File

@ -39,6 +39,7 @@ import me.mrCookieSlime.Slimefun.api.Slimefun;
* and {@link BlockBreakEvent}.
*
* @author TheBusyBiscuit
* @author Linox
*
* @see BlockPlaceHandler
* @see BlockBreakHandler
@ -51,32 +52,42 @@ 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 {
if (SlimefunPlugin.getBlockDataService().isTileEntity(e.getBlock().getType())) {
SlimefunPlugin.getBlockDataService().setBlockData(e.getBlock(), sfItem.getID());
SlimefunPlugin.getBlockDataService().setBlockData(e.getBlock(), sfItem.getId());
}
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getID(), true);
BlockStorage.addBlockInfo(e.getBlock(), "id", sfItem.getId(), true);
sfItem.callItemHandler(BlockPlaceHandler.class, handler -> handler.onPlayerPlace(e));
}
}
}
@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());
@ -118,7 +131,7 @@ public class BlockListener implements Listener {
}
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
if (blockHandler != null) {
if (!blockHandler.onBreak(e.getPlayer(), e.getBlock(), sfItem, UnregisterReason.PLAYER_BREAK)) {
@ -167,7 +180,7 @@ public class BlockListener implements Listener {
SlimefunItem sfItem = BlockStorage.check(blockAbove);
if (sfItem != null && !sfItem.useVanillaBlockBreaking()) {
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getID());
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(sfItem.getId());
if (blockHandler != null) {
if (blockHandler.onBreak(p, blockAbove, sfItem, UnregisterReason.PLAYER_BREAK)) {
@ -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

@ -47,6 +47,6 @@ public class CargoNodeListener implements Listener {
return false;
}
return sfItem.getID().equals(SlimefunItems.CARGO_INPUT_NODE.getItemId()) || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE.getItemId()) || sfItem.getID().equals(SlimefunItems.CARGO_OUTPUT_NODE_2.getItemId());
return sfItem.getId().equals(SlimefunItems.CARGO_INPUT_NODE.getItemId()) || sfItem.getId().equals(SlimefunItems.CARGO_OUTPUT_NODE.getItemId()) || sfItem.getId().equals(SlimefunItems.CARGO_OUTPUT_NODE_2.getItemId());
}
}

View File

@ -104,7 +104,7 @@ public class DebugFishListener implements Listener {
p.sendMessage(" ");
p.sendMessage(ChatColors.color("&d" + b.getType() + " &e@ X: " + b.getX() + " Y: " + b.getY() + " Z: " + b.getZ()));
p.sendMessage(ChatColors.color("&dId: " + "&e" + item.getID()));
p.sendMessage(ChatColors.color("&dId: " + "&e" + item.getId()));
p.sendMessage(ChatColors.color("&dPlugin: " + "&e" + item.getAddon().getName()));
if (b.getState() instanceof Skull) {

View File

@ -36,7 +36,7 @@ public class ExplosionsListener implements Listener {
blocks.remove();
if (!(item instanceof WitherProof)) {
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(item.getID());
SlimefunBlockHandler blockHandler = SlimefunPlugin.getRegistry().getBlockHandlers().get(item.getId());
boolean success = true;
if (blockHandler != null) {

View File

@ -94,7 +94,7 @@ public class PiglinListener implements Listener {
int chance = ((PiglinBarterDrop) sfi).getBarteringLootChance();
if (chance < 1 || chance >= 100) {
sfi.warn("The Piglin Bartering chance must be between 1-99% on item: " + sfi.getID());
sfi.warn("The Piglin Bartering chance must be between 1-99% on item: " + sfi.getId());
} else if (chance > ThreadLocalRandom.current().nextInt(100)) {
e.getItemDrop().setItemStack(sfi.getRecipeOutput());
return;

View File

@ -65,7 +65,7 @@ public class SlimefunBootsListener implements Listener {
if (boots instanceof StomperBoots) {
e.setCancelled(true);
((StomperBoots) boots).stomp(e);
} else if (boots.getID().equals("SLIME_BOOTS") || boots.getID().equals("SLIME_STEEL_BOOTS")) {
} else if (boots.getId().equals("SLIME_BOOTS") || boots.getId().equals("SLIME_STEEL_BOOTS")) {
e.setCancelled(true);
}
}
@ -75,7 +75,7 @@ public class SlimefunBootsListener implements Listener {
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)) {
if (boots != null && boots.getId().equals("ENDER_BOOTS") && Slimefun.hasUnlocked(p, boots, true)) {
e.setCancelled(true);
}
}

View File

@ -96,7 +96,7 @@ public class SlimefunItemListener implements Listener {
boolean interactable = optional.get().callItemHandler(BlockUseHandler.class, handler -> handler.onRightClick(event));
if (!interactable) {
String id = optional.get().getID();
String id = optional.get().getId();
Player p = e.getPlayer();
if (BlockMenuPreset.isInventory(id)) {

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

@ -35,7 +35,7 @@ public class WitherListener implements Listener {
SlimefunItem item = BlockStorage.check(e.getBlock());
// Hardened Glass is excluded from here
if (item instanceof WitherProof && !item.getID().equals(SlimefunItems.HARDENED_GLASS.getItemId())) {
if (item instanceof WitherProof && !item.getId().equals(SlimefunItems.HARDENED_GLASS.getItemId())) {
e.setCancelled(true);
((WitherProof) item).onAttack(e.getBlock(), (Wither) e.getEntity());
}

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

@ -247,7 +247,7 @@ public final class PostSetup {
private static boolean isDust(@Nonnull ItemStack item) {
SlimefunItem sfItem = SlimefunItem.getByItem(item);
return sfItem != null && sfItem.getID().endsWith("_DUST");
return sfItem != null && sfItem.getId().endsWith("_DUST");
}
private static void registerMachineRecipe(String machine, int seconds, ItemStack[] input, ItemStack[] output) {

View File

@ -15,9 +15,8 @@ import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
* This static setup class is used to register all default implementations of
* {@link Research} on startup.
*
* @author TheBusyBiscuit
*
* @see Research
* @see SlimefunItems
*
*/
public final class ResearchSetup {
@ -279,6 +278,7 @@ public final class ResearchSetup {
register("even_higher_tier_capacitors", 266, "Tier 3 Capacitors", 40, SlimefunItems.ENERGIZED_CAPACITOR);
register("caveman_talisman", 267, "Talisman of the Caveman", 20, SlimefunItems.TALISMAN_CAVEMAN);
register("elytra_cap", 268, "Crash Gear", 20, SlimefunItems.ELYTRA_CAP);
register("energy_connectors", 269, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR);
}
@ParametersAreNonnullByDefault

View File

@ -64,6 +64,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.CargoOutput
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.ReactorAccessPort;
import io.github.thebusybiscuit.slimefun4.implementation.items.cargo.TrashCan;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.Capacitor;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyConnector;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.EnergyRegulator;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.JetBoots;
import io.github.thebusybiscuit.slimefun4.implementation.items.electric.gadgets.Jetpack;
@ -202,8 +203,6 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* This static utility class holds the recipes of all items.
* This is the place where all items from Slimefun are registered.
*
* @author TheBusyBiscuit
*
*/
public final class SlimefunItemSetup {
@ -1507,13 +1506,18 @@ public final class SlimefunItemSetup {
new ItemStack[] {SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.ELECTRIC_MOTOR, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT, SlimefunItems.DAMASCUS_STEEL_INGOT, SlimefunItems.SILVER_INGOT})
.register(plugin);
new EnergyConnector(categories.electricity, SlimefunItems.ENERGY_CONNECTOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.CARBON, SlimefunItems.COPPER_WIRE, SlimefunItems.CARBON, SlimefunItems.COPPER_WIRE, new ItemStack(Material.REDSTONE_BLOCK), SlimefunItems.COPPER_WIRE, SlimefunItems.CARBON, SlimefunItems.COPPER_WIRE, SlimefunItems.CARBON},
new SlimefunItemStack(SlimefunItems.ENERGY_CONNECTOR, 8))
.register(plugin);
new SlimefunItem(categories.misc, SlimefunItems.DUCT_TAPE, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.ALUMINUM_DUST, SlimefunItems.ALUMINUM_DUST, SlimefunItems.ALUMINUM_DUST, new ItemStack(Material.SLIME_BALL), new ItemStack(Material.WHITE_WOOL), new ItemStack(Material.SLIME_BALL), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER), new ItemStack(Material.PAPER)},
new SlimefunItemStack(SlimefunItems.DUCT_TAPE, 2))
.register(plugin);
new Capacitor(categories.electricity, 128, SlimefunItems.SMALL_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[] {SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.SULFATE, new ItemStack(Material.REDSTONE), SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT})
new ItemStack[] {SlimefunItems.DURALUMIN_INGOT, SlimefunItems.SULFATE, SlimefunItems.DURALUMIN_INGOT, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.ENERGY_CONNECTOR, SlimefunItems.REDSTONE_ALLOY, SlimefunItems.DURALUMIN_INGOT, new ItemStack(Material.REDSTONE), SlimefunItems.DURALUMIN_INGOT})
.register(plugin);
new Capacitor(categories.electricity, 512, SlimefunItems.MEDIUM_CAPACITOR, RecipeType.ENHANCED_CRAFTING_TABLE,

View File

@ -187,7 +187,7 @@ public class TickerTask implements Runnable {
new ErrorReport<>(x, l, item);
bugs.put(position, errors);
} else if (errors == 4) {
Slimefun.getLogger().log(Level.SEVERE, "X: {0} Y: {1} Z: {2} ({3})", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ(), item.getID() });
Slimefun.getLogger().log(Level.SEVERE, "X: {0} Y: {1} Z: {2} ({3})", new Object[] { l.getBlockX(), l.getBlockY(), l.getBlockZ(), item.getId() });
Slimefun.getLogger().log(Level.SEVERE, "has thrown 4 error messages in the last 4 Ticks, the Block has been terminated.");
Slimefun.getLogger().log(Level.SEVERE, "Check your /plugins/Slimefun/error-reports/ folder for details.");
Slimefun.getLogger().log(Level.SEVERE, " ");

View File

@ -62,6 +62,7 @@ public enum HeadTexture {
FUEL_BUCKET("a84ddca766725b8b97413f259c3f7668070f6ae55483a90c8e5525394f9c099"),
ELECTRIC_PRESS("8d5cf92bc79ec19f4106441affff1406a1367010dcafb197dd94cfca1a6de0fc"),
ENERGY_REGULATOR("d78f2b7e5e75639ea7fb796c35d364c4df28b4243e66b76277aadcd6261337"),
ENERGY_CONNECTOR("1085e098756b995b00241644089c55a8f9acde35b9a37785d5e057a923613b"),
NETHER_ICE("3ce2dad9baf7eaba7e80d4d0f9fac0aab01a76b12fb71c3d2af2a16fdd4c7383"),
ENRICHED_NETHER_ICE("7c818aa13aabc7294838d21caac057e97bd8c89641a0c0f8a55442ff4e27"),
NETHER_ICE_COOLANT_CELL("8d3cd412555f897016213e5d6c7431b448b9e5644e1b19ec51b5316f35840e0"),

View File

@ -4,6 +4,8 @@ import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.util.Locale;
import javax.annotation.Nonnull;
import io.github.thebusybiscuit.slimefun4.core.attributes.MachineTier;
import io.github.thebusybiscuit.slimefun4.core.attributes.MachineType;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity;
@ -31,40 +33,54 @@ public final class LoreBuilder {
private LoreBuilder() {}
public static String radioactive(Radioactivity radioactivity) {
@Nonnull
public static String radioactive(@Nonnull Radioactivity radioactivity) {
return radioactivity.getLore();
}
public static String machine(MachineTier tier, MachineType type) {
@Nonnull
public static String machine(@Nonnull MachineTier tier, @Nonnull MachineType type) {
return tier + " " + type;
}
@Nonnull
public static String speed(float speed) {
return "&8\u21E8 &b\u26A1 &7Speed: &b" + speed + 'x';
}
@Nonnull
public static String powerBuffer(int power) {
return power(power, " Buffer");
}
@Nonnull
public static String powerPerSecond(int power) {
return power(power, "/s");
}
public static String power(int power, String suffix) {
@Nonnull
public static String power(int power, @Nonnull String suffix) {
return "&8\u21E8 &e\u26A1 &7" + power + " J" + suffix;
}
@Nonnull
public static String powerCharged(int charge, int capacity) {
return "&8\u21E8 &e\u26A1 &7" + charge + " / " + capacity + " J";
}
public static String material(String material) {
@Nonnull
public static String material(@Nonnull String material) {
return "&8\u21E8 &7Material: &b" + material;
}
@Nonnull
public static String hunger(double value) {
return "&7&oRestores &b&o" + hungerFormat.format(value) + " &7&oHunger";
}
@Nonnull
public static String range(int blocks) {
return "&7Range: &c" + blocks + " blocks";
}
}

View File

@ -63,6 +63,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.

View File

@ -51,25 +51,66 @@ import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import me.mrCookieSlime.Slimefun.Objects.handlers.ItemHandler;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
/**
* A {@link SlimefunItem} is a custom item registered by a {@link SlimefunAddon}.
* This class defines the behaviours of the item, you can assign an {@link ItemHandler}
* to give the item functionality.
* In contrast to that the {@link SlimefunItemStack} defines the look and feel of the item.
*
* Remember to call {@link #register(SlimefunAddon)} on your {@link SlimefunItem} for it
* to appear in the {@link SlimefunGuide}.
*
* @author TheBusyBiscuit
* @author Poslovitch
*
* @see SlimefunItemStack
* @see SlimefunAddon
*
*/
public class SlimefunItem implements Placeable {
/**
* This is our item id.
*/
private final String id;
/**
* This is the original {@link ItemStack} that represents this item.
* It is immutable and should always be cloned, never used directly.
*/
private final ItemStack itemStackTemplate;
/**
* This is a reference to the {@link SlimefunAddon} that registered this
* {@link SlimefunItem}, if the item has not been registered yet, it will be null.
*/
private SlimefunAddon addon;
/**
* This is the state of this {@link SlimefunItem}.
*/
private ItemState state = ItemState.UNREGISTERED;
protected String id;
protected SlimefunAddon addon;
protected ItemStack item;
protected Category category;
protected ItemStack[] recipe;
protected RecipeType recipeType;
/**
* This is the {@link Category} in which this {@link SlimefunItem} can be found.
*/
private Category category;
/**
* This is a reference to the associated {@link Research}, can be null.
*/
private Research research;
private ItemStack[] recipe;
private RecipeType recipeType;
protected ItemStack recipeOutput;
protected Research research;
protected boolean enchantable = true;
protected boolean disenchantable = true;
protected boolean hidden = false;
protected boolean useableInWorkbench = false;
private Optional<String> wikiLink = Optional.empty();
private Optional<String> wikiURL = Optional.empty();
private final OptionalMap<Class<? extends ItemHandler>, ItemHandler> itemhandlers = new OptionalMap<>(HashMap::new);
private final Set<ItemSetting<?>> itemSettings = new HashSet<>();
@ -113,7 +154,7 @@ public class SlimefunItem implements Placeable {
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
this.category = category;
this.item = item;
this.itemStackTemplate = item;
this.id = item.getItemId();
this.recipeType = recipeType;
this.recipe = recipe;
@ -128,19 +169,32 @@ public class SlimefunItem implements Placeable {
Validate.notNull(recipeType, "'recipeType' is not allowed to be null!");
this.category = category;
this.item = item;
this.itemStackTemplate = item;
this.id = id;
this.recipeType = recipeType;
this.recipe = recipe;
}
/**
* Returns the identifier of this {@link SlimefunItem}.
*
* @deprecated This method has been renamed to {@link #getId()}.
*
* @return the identifier of this {@link SlimefunItem}
*/
@Nonnull
@Deprecated
public final String getID() {
return getId();
}
/**
* Returns the identifier of this {@link SlimefunItem}.
*
* @return the identifier of this {@link SlimefunItem}
*/
@Nonnull
public final String getID() {
public final String getId() {
return id;
}
@ -166,7 +220,7 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public ItemStack getItem() {
return item;
return itemStackTemplate;
}
/**
@ -195,7 +249,7 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public ItemStack getRecipeOutput() {
return recipeOutput != null ? recipeOutput.clone() : item.clone();
return recipeOutput != null ? recipeOutput.clone() : itemStackTemplate.clone();
}
/**
@ -229,11 +283,12 @@ public class SlimefunItem implements Placeable {
* The key of this {@link ItemSetting}
* @param c
* The {@link Class} of the type of value stored by this setting
*
* @return An {@link Optional} describing the result
*/
@SuppressWarnings("unchecked")
@Nonnull
public <T> Optional<ItemSetting<T>> getItemSetting(String key, Class<T> c) {
public <T> Optional<ItemSetting<T>> getItemSetting(@Nonnull String key, @Nonnull Class<T> c) {
for (ItemSetting<?> setting : itemSettings) {
if (setting.getKey().equals(key) && setting.isType(c)) {
return Optional.of((ItemSetting<T>) setting);
@ -315,10 +370,10 @@ public class SlimefunItem implements Placeable {
*
* @return The {@link SlimefunAddon} that registered this {@link SlimefunItem}
*/
@Nonnull
public SlimefunAddon getAddon() {
if (addon == null) {
error("getAddon() cannot be called before registering the item", new UnregisteredItemException(this));
return null;
throw new UnregisteredItemException(this);
}
return addon;
@ -343,17 +398,11 @@ public class SlimefunItem implements Placeable {
this.addon = addon;
try {
if (!addon.hasDependency("Slimefun")) {
throw new MissingDependencyException(addon, "Slimefun");
}
checkDependencies(addon);
checkForConflicts();
preRegister();
SlimefunItem conflicting = getByID(id);
if (conflicting != null) {
throw new IdConflictException(this, conflicting);
}
if (recipe == null || recipe.length < 9) {
recipe = new ItemStack[] { null, null, null, null, null, null, null, null, null };
}
@ -402,8 +451,8 @@ public class SlimefunItem implements Placeable {
}
// Lock the SlimefunItemStack from any accidental manipulations
if (item instanceof SlimefunItemStack && isItemStackImmutable()) {
((SlimefunItemStack) item).lock();
if (itemStackTemplate instanceof SlimefunItemStack && isItemStackImmutable()) {
((SlimefunItemStack) itemStackTemplate).lock();
}
postRegister();
@ -430,7 +479,7 @@ public class SlimefunItem implements Placeable {
category.register();
}
// Send out deprecation warnings for any classes or intefaces
// Send out deprecation warnings for any classes or interfaces
checkForDeprecations(getClass());
// Add it to the list of enabled items
@ -480,6 +529,29 @@ public class SlimefunItem implements Placeable {
return true;
}
/**
* This method checks if the dependencies have been set up correctly.
*
* @param addon
* The {@link SlimefunAddon} trying to register this {@link SlimefunItem}
*/
private void checkDependencies(@Nonnull SlimefunAddon addon) {
if (!addon.hasDependency("Slimefun")) {
throw new MissingDependencyException(addon, "Slimefun");
}
}
/**
* This method checks for id conflicts.
*/
private void checkForConflicts() {
SlimefunItem conflictingItem = getByID(id);
if (conflictingItem != null) {
throw new IdConflictException(this, conflictingItem);
}
}
/**
* This method checks recursively for all {@link Class} parents to look for any {@link Deprecated}
* elements.
@ -623,21 +695,21 @@ public class SlimefunItem implements Placeable {
// If the given item is a SlimefunitemStack, simply compare the id
if (item instanceof SlimefunItemStack) {
return getID().equals(((SlimefunItemStack) item).getItemId());
return getId().equals(((SlimefunItemStack) item).getItemId());
}
if (item.hasItemMeta()) {
Optional<String> itemId = SlimefunPlugin.getItemDataService().getItemData(item);
if (itemId.isPresent()) {
return getID().equals(itemId.get());
return getId().equals(itemId.get());
}
}
// Backwards compatibility
if (SlimefunPlugin.getRegistry().isBackwardsCompatible()) {
boolean loreInsensitive = this instanceof Rechargeable || this instanceof SlimefunBackpack || id.equals("BROKEN_SPAWNER") || id.equals("REINFORCED_SPAWNER");
return SlimefunUtils.isItemSimilar(item, this.item, !loreInsensitive);
return SlimefunUtils.isItemSimilar(item, this.itemStackTemplate, !loreInsensitive);
} else {
return false;
}
@ -679,7 +751,7 @@ public class SlimefunItem implements Placeable {
// Tickers are a special case (at the moment at least)
if (handler instanceof BlockTicker) {
ticking = true;
SlimefunPlugin.getRegistry().getTickerBlocks().add(getID());
SlimefunPlugin.getRegistry().getTickerBlocks().add(getId());
blockTicker = (BlockTicker) handler;
}
}
@ -747,7 +819,7 @@ public class SlimefunItem implements Placeable {
*/
public final void addOficialWikipage(@Nonnull String page) {
Validate.notNull(page, "Wiki page cannot be null.");
wikiLink = Optional.of("https://github.com/Slimefun/Slimefun4/wiki/" + page);
wikiURL = Optional.of("https://github.com/Slimefun/Slimefun4/wiki/" + page);
}
/**
@ -760,7 +832,7 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public Optional<String> getWikipage() {
return wikiLink;
return wikiURL;
}
/**
@ -771,15 +843,15 @@ public class SlimefunItem implements Placeable {
*/
@Nonnull
public final String getItemName() {
if (item instanceof SlimefunItemStack) {
Optional<String> name = ((SlimefunItemStack) item).getImmutableMeta().getDisplayName();
if (itemStackTemplate instanceof SlimefunItemStack) {
Optional<String> name = ((SlimefunItemStack) itemStackTemplate).getImmutableMeta().getDisplayName();
if (name.isPresent()) {
return name.get();
}
}
return ItemUtils.getItemName(item);
return ItemUtils.getItemName(itemStackTemplate);
}
/**
@ -841,7 +913,7 @@ public class SlimefunItem implements Placeable {
@Override
public Collection<ItemStack> getDrops() {
return Arrays.asList(item.clone());
return Arrays.asList(itemStackTemplate.clone());
}
@Override
@ -937,7 +1009,7 @@ public class SlimefunItem implements Placeable {
if (sfi.isItem(wrapper)) {
// If we have to loop all items for the given item, then at least
// set the id via PersistentDataAPI for future performance boosts
SlimefunPlugin.getItemDataService().setItemData(item, sfi.getID());
SlimefunPlugin.getItemDataService().setItemData(item, sfi.getId());
return sfi;
}

View File

@ -5,6 +5,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -45,12 +47,13 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
protected final List<MachineRecipe> recipes = new ArrayList<>();
@ParametersAreNonnullByDefault
public AContainer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
createPreset(this, getInventoryTitle(), this::constructMenu);
registerBlockHandler(id, (p, b, tool, reason) -> {
registerBlockHandler(item.getItemId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {
@ -66,6 +69,7 @@ public abstract class AContainer extends SlimefunItem implements InventoryBlock,
registerDefaultRecipes();
}
@ParametersAreNonnullByDefault
public AContainer(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
this(category, item, recipeType, recipe);
this.recipeOutput = recipeOutput;

View File

@ -3,6 +3,8 @@ package me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.ParametersAreNonnullByDefault;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -40,10 +42,11 @@ public abstract class AGenerator extends AbstractEnergyProvider {
private static final int[] border_in = { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 };
private static final int[] border_out = { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 };
@ParametersAreNonnullByDefault
public AGenerator(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
new BlockMenuPreset(id, getInventoryTitle()) {
new BlockMenuPreset(item.getItemId(), getInventoryTitle()) {
@Override
public void init() {
@ -65,7 +68,7 @@ public abstract class AGenerator extends AbstractEnergyProvider {
}
};
registerBlockHandler(id, (p, b, tool, reason) -> {
registerBlockHandler(item.getItemId(), (p, b, tool, reason) -> {
BlockMenu inv = BlockStorage.getInventory(b);
if (inv != null) {

View File

@ -43,7 +43,7 @@ public interface InventoryBlock {
}
default void createPreset(SlimefunItem item, String title, Consumer<BlockMenuPreset> setup) {
new BlockMenuPreset(item.getID(), title) {
new BlockMenuPreset(item.getId(), title) {
@Override
public void init() {

View File

@ -356,7 +356,7 @@ public class BlockStorage {
SlimefunItem sfitem = SlimefunItem.getByItem(item);
if (sfitem != null) {
addBlockInfo(block, "id", sfitem.getID(), true);
addBlockInfo(block, "id", sfitem.getId(), true);
}
}

View File

@ -261,6 +261,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!'
@ -278,6 +279,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

@ -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

@ -169,6 +169,7 @@ slimefun:
energized_solar_generator: Full-Time Solar Power
energized_gps_transmitter: Top Tier Transmitter
energy_regulator: Energy Networks 101
energy_connectors: Wired Connections
butcher_androids: Butcher Androids
organic_food: Organic Food
auto_breeder: Automated Feeding

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

@ -5,7 +5,7 @@ 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'

View File

@ -1,10 +1,14 @@
{
"values" : [
"#minecraft:sand",
"#minecraft:dirt_like",
"#slimefun:concrete_powders",
"minecraft:farmland",
"minecraft:dirt",
"minecraft:coarse_dirt",
"minecraft:grass_block",
"minecraft:grass_path",
"minecraft:farmland",
"minecraft:podzol",
"minecraft:mycelium",
"minecraft:snow",
"minecraft:snow_block",
"minecraft:gravel",

View File

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

View File

@ -0,0 +1,80 @@
package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.AnvilListener;
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
public class TestAnvilListener {
private static SlimefunPlugin plugin;
private static AnvilListener listener;
private static ServerMock server;
@BeforeAll
public static void load() {
server = MockBukkit.mock();
plugin = MockBukkit.load(SlimefunPlugin.class);
listener = new AnvilListener(plugin);
}
@AfterAll
public static void unload() {
MockBukkit.unmock();
}
private InventoryClickEvent mockAnvilEvent(ItemStack item) {
Player player = server.addPlayer();
Inventory inv = TestUtilities.mockInventory(InventoryType.ANVIL, item, null, new ItemStack(Material.IRON_CHESTPLATE));
InventoryView view = player.openInventory(inv);
InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 2, ClickType.LEFT, InventoryAction.PICKUP_ONE);
listener.onAnvil(event);
return event;
}
@Test
public void testAnvilWithoutSlimefunItems() {
InventoryClickEvent event = mockAnvilEvent(new ItemStack(Material.IRON_SWORD));
Assertions.assertEquals(Result.DEFAULT, event.getResult());
}
@Test
public void testAnvilWithSlimefunItem() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCKED_IRON_SWORD", new CustomItem(Material.IRON_SWORD, "&6Mock"));
item.register(plugin);
InventoryClickEvent event = mockAnvilEvent(item.getItem());
Assertions.assertEquals(Result.DENY, event.getResult());
}
@Test
public void testAnvilWithVanillaItem() {
VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.IRON_SWORD, true);
item.register(plugin);
InventoryClickEvent event = mockAnvilEvent(item.getItem());
Assertions.assertEquals(Result.DEFAULT, event.getResult());
}
}

View File

@ -0,0 +1,84 @@
package io.github.thebusybiscuit.slimefun4.testing.tests.listeners;
import org.bukkit.Material;
import org.bukkit.block.BrewingStand;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.inventory.InventoryType.SlotType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import be.seeseemelk.mockbukkit.MockBukkit;
import be.seeseemelk.mockbukkit.ServerMock;
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
import io.github.thebusybiscuit.slimefun4.implementation.listeners.crafting.BrewingStandListener;
import io.github.thebusybiscuit.slimefun4.testing.TestUtilities;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
public class TestBrewingStandListener {
private static SlimefunPlugin plugin;
private static BrewingStandListener listener;
private static ServerMock server;
@BeforeAll
public static void load() {
server = MockBukkit.mock();
plugin = MockBukkit.load(SlimefunPlugin.class);
listener = new BrewingStandListener(plugin);
}
@AfterAll
public static void unload() {
MockBukkit.unmock();
}
private InventoryClickEvent mockBrewingEvent(ItemStack item) {
Player player = server.addPlayer();
Inventory inv = TestUtilities.mockInventory(InventoryType.BREWING);
Mockito.when(inv.getHolder()).thenReturn(Mockito.mock(BrewingStand.class));
Mockito.when(inv.getSize()).thenReturn(5);
InventoryView view = player.openInventory(inv);
view.setCursor(item);
InventoryClickEvent event = new InventoryClickEvent(view, SlotType.CONTAINER, 1, ClickType.LEFT, InventoryAction.PICKUP_ONE);
listener.onPreBrew(event);
return event;
}
@Test
public void testBrewingWithoutSlimefunItems() {
InventoryClickEvent event = mockBrewingEvent(new ItemStack(Material.BLAZE_POWDER));
Assertions.assertEquals(Result.ALLOW, event.getResult());
}
@Test
public void testBrewingWithSlimefunItem() {
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "MOCK_POWDER", new CustomItem(Material.BLAZE_POWDER, "&6Magic Mock Powder"));
item.register(plugin);
InventoryClickEvent event = mockBrewingEvent(item.getItem());
Assertions.assertEquals(Result.DENY, event.getResult());
}
@Test
public void testBrewingWithVanillaItem() {
VanillaItem item = TestUtilities.mockVanillaItem(plugin, Material.BLAZE_POWDER, true);
item.register(plugin);
InventoryClickEvent event = mockBrewingEvent(item.getItem());
Assertions.assertEquals(Result.ALLOW, event.getResult());
}
}

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