mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 19:55:48 +00:00
Merge branch 'master' into MoreTalismans
This commit is contained in:
commit
db95cca3fb
@ -39,6 +39,7 @@
|
||||
* 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
|
||||
|
||||
#### Changes
|
||||
* Improved Auto-Updater (Multi-Threading and more)
|
||||
@ -76,6 +77,10 @@
|
||||
* Fixed #2420
|
||||
* Fixed #2422
|
||||
* Fixed #2433
|
||||
* Fixed #2455
|
||||
* Fixed #2450
|
||||
* Fixed Steel Thrusters being used to milk cows
|
||||
* Fixed #2424
|
||||
|
||||
## Release Candidate 16 (07 Sep 2020)
|
||||
https://thebusybiscuit.github.io/builds/TheBusyBiscuit/Slimefun4/stable/#16
|
||||
|
@ -159,7 +159,7 @@ if (something) {
|
||||
// Actual code...
|
||||
```
|
||||
* if/else statements should always include a bracket, please avoid one-line statements. (e.g. Avoid doing: `if (x == 0) return;`)
|
||||
* We do not enforce any particular width or column limit, but try to prevent your lines from becoming too long.
|
||||
* We do not enforce any particular width or column limit, just try to prevent your lines from becoming too long. But please avoid line-wrapping.
|
||||
* Annotations for methods or fields should never go on the same line, place them on the line above.
|
||||
* Comments should never go on the same line as code! Always above or below.
|
||||
* Make sure that empty lines are truly empty, they should not contain any whitespace characters.
|
||||
|
@ -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();
|
||||
});
|
||||
|
@ -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") + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 });
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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) + "}";
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -94,7 +94,7 @@ abstract class GitHubConnector {
|
||||
}
|
||||
} catch (UnirestException e) {
|
||||
if (github.isLoggingEnabled()) {
|
||||
Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time.");
|
||||
Slimefun.getLogger().log(Level.WARNING, "Could not connect to GitHub in time.", e);
|
||||
}
|
||||
|
||||
// It has the cached file, let's just read that then
|
||||
|
@ -88,7 +88,7 @@ class GitHubTask implements Runnable {
|
||||
} catch (IOException x) {
|
||||
// Too many requests
|
||||
Slimefun.getLogger().log(Level.WARNING, "Attempted to connect to mojang.com, got this response: {0}: {1}", new Object[] { x.getClass().getSimpleName(), x.getMessage() });
|
||||
Slimefun.getLogger().log(Level.WARNING, "This usually means mojang.com is down or started to rate-limit this connection, this is not an error message!");
|
||||
Slimefun.getLogger().log(Level.WARNING, "This usually means mojang.com is temporarily down or started to rate-limit this connection, this is not an error message!");
|
||||
|
||||
// Retry after 5 minutes if it was rate-limiting
|
||||
if (x.getMessage().contains("429")) {
|
||||
|
@ -46,7 +46,7 @@ class ProfiledBlock {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return item.getID();
|
||||
return item.getId();
|
||||
}
|
||||
|
||||
public SlimefunAddon getAddon() {
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -674,12 +674,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");
|
||||
@ -752,6 +752,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);
|
||||
|
@ -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();
|
||||
|
@ -2,6 +2,10 @@ package io.github.thebusybiscuit.slimefun4.implementation.items.altar;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -17,7 +21,9 @@ import org.bukkit.util.Vector;
|
||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||
import io.github.thebusybiscuit.cscorelib2.inventory.ItemUtils;
|
||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunPlugin;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.SimpleSlimefunItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.listeners.AncientAltarListener;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.tasks.AncientAltarTask;
|
||||
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
|
||||
@ -39,14 +45,15 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
* @see AncientAltarTask
|
||||
*
|
||||
*/
|
||||
public class AncientPedestal extends SlimefunItem {
|
||||
public class AncientPedestal extends SimpleSlimefunItem<BlockDispenseHandler> {
|
||||
|
||||
public static final String ITEM_PREFIX = ChatColors.color("&dALTAR &3Probe - &e");
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
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()) {
|
||||
@ -63,7 +70,13 @@ public class AncientPedestal extends SlimefunItem {
|
||||
});
|
||||
}
|
||||
|
||||
public Optional<Item> getPlacedItem(Block pedestal) {
|
||||
@Override
|
||||
public BlockDispenseHandler getItemHandler() {
|
||||
return (e, d, block, machine) -> e.setCancelled(true);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Optional<Item> getPlacedItem(@Nonnull Block pedestal) {
|
||||
Location l = pedestal.getLocation().add(0.5, 1.2, 0.5);
|
||||
|
||||
for (Entity n : l.getWorld().getNearbyEntities(l, 0.5, 0.5, 0.5, this::testItem)) {
|
||||
@ -75,7 +88,7 @@ public class AncientPedestal extends SlimefunItem {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private boolean testItem(Entity n) {
|
||||
private boolean testItem(@Nullable Entity n) {
|
||||
if (n instanceof Item && n.isValid()) {
|
||||
Item item = (Item) n;
|
||||
ItemMeta meta = item.getItemStack().getItemMeta();
|
||||
@ -86,7 +99,8 @@ public class AncientPedestal extends SlimefunItem {
|
||||
}
|
||||
}
|
||||
|
||||
public ItemStack getOriginalItemStack(Item item) {
|
||||
@Nonnull
|
||||
public ItemStack getOriginalItemStack(@Nonnull Item item) {
|
||||
ItemStack stack = item.getItemStack().clone();
|
||||
String customName = item.getCustomName();
|
||||
|
||||
@ -108,7 +122,7 @@ public class AncientPedestal extends SlimefunItem {
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void placeItem(Player p, Block b) {
|
||||
public void placeItem(@Nonnull Player p, @Nonnull Block b) {
|
||||
ItemStack hand = p.getInventory().getItemInMainHand();
|
||||
ItemStack displayItem = new CustomItem(hand, ITEM_PREFIX + System.nanoTime());
|
||||
displayItem.setAmount(1);
|
||||
|
@ -0,0 +1,34 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.androids;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.BlockDispenseHandler;
|
||||
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;
|
||||
|
||||
/**
|
||||
* The {@link AndroidInterface} are inventories used to interact with a {@link ProgrammableAndroid}.
|
||||
* There are two variants of interfaces, fuel and items.
|
||||
*
|
||||
* @author TheBusyBiscuit
|
||||
*
|
||||
* @see ProgrammableAndroid
|
||||
*
|
||||
*/
|
||||
public class AndroidInterface extends SimpleSlimefunItem<BlockDispenseHandler> {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public AndroidInterface(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockDispenseHandler getItemHandler() {
|
||||
return (e, d, block, machine) -> e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
@ -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) {
|
||||
|
@ -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));
|
||||
|
@ -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() {
|
||||
|
@ -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) {
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
});
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
});
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
@ -360,7 +360,7 @@ public abstract class Reactor extends AbstractEnergyProvider {
|
||||
inv.replaceExistingItem(22, new CustomItem(Material.BLACK_STAINED_GLASS_PANE, " "));
|
||||
|
||||
if (processing.get(l).getOutput() != null) {
|
||||
inv.pushItem(processing.get(l).getOutput(), getOutputSlots());
|
||||
inv.pushItem(processing.get(l).getOutput().clone(), getOutputSlots());
|
||||
}
|
||||
|
||||
if (accessPort != null) {
|
||||
|
@ -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);
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -79,7 +79,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;
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class Talisman extends SlimefunItem {
|
||||
@Override
|
||||
public void postRegister() {
|
||||
EnderTalisman talisman = new EnderTalisman(this, getEnderVariant());
|
||||
talisman.register(addon);
|
||||
talisman.register(getAddon());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,41 @@
|
||||
package io.github.thebusybiscuit.slimefun4.implementation.items.misc;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import org.bukkit.entity.Cow;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler;
|
||||
import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler;
|
||||
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
|
||||
import me.mrCookieSlime.Slimefun.Objects.Category;
|
||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
||||
|
||||
public class SteelThruster extends SlimefunItem {
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public SteelThruster(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
|
||||
super(category, item, recipeType, recipe);
|
||||
|
||||
addItemHandler(onRightClickBlock(), onRightClickEntity());
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private ItemUseHandler onRightClickBlock() {
|
||||
return PlayerRightClickEvent::cancel;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private EntityInteractHandler onRightClickEntity() {
|
||||
return (e, item, hand) -> {
|
||||
// Milking cows with a rocket engine? Yeah, that would be weird.
|
||||
if (e.getRightClicked() instanceof Cow) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -66,10 +66,10 @@ public class BlockListener implements Listener {
|
||||
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));
|
||||
}
|
||||
}
|
||||
@ -118,7 +118,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 +167,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)) {
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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)) {
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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,8 +278,9 @@ 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("wise_talisman", 269, "Talisman of the Wise", 20, SlimefunItems.TALISMAN_WISE);
|
||||
register("resurrected_talisman", 270, "Talisman of the Resurrected", 20, SlimefunItems.TALISMAN_RESURRECTED);
|
||||
register("energy_connectors", 269, "Wired Connections", 12, SlimefunItems.ENERGY_CONNECTOR);
|
||||
register("wise_talisman", 270, "Talisman of the Wise", 20, SlimefunItems.TALISMAN_WISE);
|
||||
register("resurrected_talisman", 271, "Talisman of the Resurrected", 20, SlimefunItems.TALISMAN_RESURRECTED);
|
||||
}
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
|
@ -27,6 +27,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.VanillaItem;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientAltar;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.altar.AncientPedestal;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AdvancedFarmerAndroid;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.AndroidInterface;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.ButcherAndroid;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FarmerAndroid;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.androids.FisherAndroid;
|
||||
@ -64,6 +65,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;
|
||||
@ -111,11 +113,11 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.electric.reactors
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.BirthdayCake;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.DietCookie;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.FortuneCookie;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.Juice;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MagicSugar;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MeatJerky;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.MonsterJerky;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.food.HeavyCream;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.OilPump;
|
||||
@ -151,6 +153,7 @@ import io.github.thebusybiscuit.slimefun4.implementation.items.misc.BasicCircuit
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.CoolantCell;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFertilizer;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.OrganicFood;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SteelThruster;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.StrangeNetherGoo;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.misc.SyntheticEmerald;
|
||||
import io.github.thebusybiscuit.slimefun4.implementation.items.multiblocks.ArmorForge;
|
||||
@ -202,8 +205,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 {
|
||||
|
||||
@ -608,7 +609,7 @@ public final class SlimefunItemSetup {
|
||||
new ItemStack[] {SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, new ItemStack(Material.FLINT), SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON, SlimefunItems.COMPRESSED_CARBON})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.technicalComponents, SlimefunItems.STEEL_THRUSTER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new SteelThruster(categories.technicalComponents, SlimefunItems.STEEL_THRUSTER, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {null, new ItemStack(Material.REDSTONE), null, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.ALUMINUM_BRONZE_INGOT, SlimefunItems.STEEL_PLATE, new ItemStack(Material.FIRE_CHARGE), SlimefunItems.STEEL_PLATE})
|
||||
.register(plugin);
|
||||
|
||||
@ -1515,13 +1516,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,
|
||||
@ -2191,11 +2197,11 @@ public final class SlimefunItemSetup {
|
||||
new ItemStack[] {null, SlimefunItems.ELECTRO_MAGNET, null, null, SlimefunItems.GPS_TRANSMITTER, null, null, SlimefunItems.ESSENCE_OF_AFTERLIFE, null})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.androids, SlimefunItems.ANDROID_INTERFACE_ITEMS, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new AndroidInterface(categories.androids, SlimefunItems.ANDROID_INTERFACE_ITEMS, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.BASIC_CIRCUIT_BOARD, new ItemStack(Material.BLUE_STAINED_GLASS), SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET})
|
||||
.register(plugin);
|
||||
|
||||
new SlimefunItem(categories.androids, SlimefunItems.ANDROID_INTERFACE_FUEL, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new AndroidInterface(categories.androids, SlimefunItems.ANDROID_INTERFACE_FUEL, RecipeType.ENHANCED_CRAFTING_TABLE,
|
||||
new ItemStack[] {SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET, new ItemStack(Material.RED_STAINED_GLASS), SlimefunItems.BASIC_CIRCUIT_BOARD, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET, SlimefunItems.STEEL_INGOT, SlimefunItems.PLASTIC_SHEET})
|
||||
.register(plugin);
|
||||
|
||||
|
@ -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, " ");
|
||||
|
@ -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"),
|
||||
|
@ -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";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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,7 +169,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 = id;
|
||||
this.recipeType = recipeType;
|
||||
this.recipe = recipe;
|
||||
@ -137,10 +178,23 @@ public class SlimefunItem implements Placeable {
|
||||
/**
|
||||
* 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() {
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,6 +171,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
|
||||
|
@ -50,7 +50,7 @@ public class TestSlimefunItemRegistration {
|
||||
|
||||
Assertions.assertEquals(ItemState.ENABLED, item.getState());
|
||||
Assertions.assertFalse(item.isDisabled());
|
||||
Assertions.assertEquals(id, item.getID());
|
||||
Assertions.assertEquals(id, item.getId());
|
||||
Assertions.assertEquals(item, SlimefunItem.getByID(id));
|
||||
}
|
||||
|
||||
@ -176,7 +176,7 @@ public class TestSlimefunItemRegistration {
|
||||
Assertions.assertFalse(sfItem.isItem(new CustomItem(Material.BEACON, "&cItem Test")));
|
||||
}
|
||||
|
||||
Assertions.assertEquals(sfItem, SlimefunItem.getByItem(new SlimefunItemStack(sfItem.getID(), item)));
|
||||
Assertions.assertEquals(sfItem, SlimefunItem.getByItem(new SlimefunItemStack(sfItem.getId(), item)));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -60,17 +60,17 @@ class TextCustomTextureService {
|
||||
SlimefunItem item = TestUtilities.mockSlimefunItem(plugin, "TEXTURE_TEST", new ItemStack(Material.LANTERN));
|
||||
String version = "Unit Test v1.0";
|
||||
|
||||
config.setValue(item.getID(), 300);
|
||||
config.setValue(item.getId(), 300);
|
||||
config.setValue("version", version);
|
||||
|
||||
service.register(Arrays.asList(item), false);
|
||||
|
||||
Assertions.assertTrue(service.isActive());
|
||||
Assertions.assertEquals(version, service.getVersion());
|
||||
Assertions.assertEquals(300, service.getModelData(item.getID()));
|
||||
Assertions.assertEquals(300, service.getModelData(item.getId()));
|
||||
|
||||
ItemStack stack = new ItemStack(Material.DIAMOND);
|
||||
service.setTexture(stack, item.getID());
|
||||
service.setTexture(stack, item.getId());
|
||||
|
||||
Assertions.assertTrue(stack.getItemMeta().hasCustomModelData());
|
||||
Assertions.assertEquals(300, stack.getItemMeta().getCustomModelData());
|
||||
|
Loading…
Reference in New Issue
Block a user