mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
[CI skip] Some API changes
This commit is contained in:
parent
9a1e9bcefc
commit
ad6dfb676c
@ -48,7 +48,8 @@
|
|||||||
## Release Candidate 11 (TBD)
|
## Release Candidate 11 (TBD)
|
||||||
|
|
||||||
#### Additions
|
#### Additions
|
||||||
* Added experimental 1.13 backwards compatibility
|
* Added GEOResourceGenerationEvent
|
||||||
|
* Added SlimefunGuide-Options API
|
||||||
|
|
||||||
#### Changes
|
#### Changes
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ Here is a full summary of the differences between these two versions of Slimefun
|
|||||||
|
|
||||||
| | development builds | "stable" builds |
|
| | development builds | "stable" builds |
|
||||||
| ------------------ | -------- | -------- |
|
| ------------------ | -------- | -------- |
|
||||||
| **Supported Minecraft version(s)** | 1.14.X - 1.15.X | 1.14.X - 1.15.X |
|
| **Supported Minecraft version(s)** | 1.13.X - 1.15.X | 1.14.X - 1.15.X |
|
||||||
| **extensive testing before release** | :x: | :heavy_check_mark: |
|
| **extensive testing before release** | :x: | :heavy_check_mark: |
|
||||||
| **latest content** | :heavy_check_mark: | :x: |
|
| **latest content** | :heavy_check_mark: | :x: |
|
||||||
| **Discord support** | :heavy_check_mark: | :x: |
|
| **Discord support** | :heavy_check_mark: | :x: |
|
||||||
|
@ -0,0 +1,140 @@
|
|||||||
|
package io.github.thebusybiscuit.slimefun4.api.events;
|
||||||
|
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.World.Environment;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.geo.ResourceManager;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOScanner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link Event} is fired whenever a {@link GEOResource} is being freshly generated.
|
||||||
|
* This only ocurs when a {@link GEOScanner} queries the {@link Chunk} for a {@link GEOResource}
|
||||||
|
* but cannot find it.
|
||||||
|
*
|
||||||
|
* You can modify this {@link Event} by listening to it.
|
||||||
|
*
|
||||||
|
* @author TheBusyBiscuit
|
||||||
|
*
|
||||||
|
* @see ResourceManager
|
||||||
|
* @see GEOResource
|
||||||
|
* @see GEOScanner
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class GEOResourceGenerationEvent extends Event {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
private final World world;
|
||||||
|
private final Biome biome;
|
||||||
|
private final GEOResource resource;
|
||||||
|
private final int x;
|
||||||
|
private final int z;
|
||||||
|
|
||||||
|
private int value;
|
||||||
|
|
||||||
|
public GEOResourceGenerationEvent(World world, Biome biome, int x, int z, GEOResource resource, int value) {
|
||||||
|
this.world = world;
|
||||||
|
this.biome = biome;
|
||||||
|
this.resource = resource;
|
||||||
|
this.x = x;
|
||||||
|
this.z = z;
|
||||||
|
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the amount that will be generated of this {@link GEOResource}.
|
||||||
|
*
|
||||||
|
* @return The value aka the supply of this {@link GEOResource} to generate
|
||||||
|
*/
|
||||||
|
public int getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This modifies the amount that will be generated.
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
* The new supply for this {@link GEOResource}
|
||||||
|
*/
|
||||||
|
public void setValue(int value) {
|
||||||
|
if (value < 0) {
|
||||||
|
throw new IllegalArgumentException("You cannot set a GEO-Resource supply to a negative value.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link World} in which this event takes place.
|
||||||
|
*
|
||||||
|
* @return The affected {@link World}
|
||||||
|
*/
|
||||||
|
public World getWorld() {
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the {@link GEOResource} that is being generated
|
||||||
|
*
|
||||||
|
* @return The generated {@link GEOResource}
|
||||||
|
*/
|
||||||
|
public GEOResource getResource() {
|
||||||
|
return resource;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the X coordinate of the {@link Chunk} in which the {@link GEOResource}
|
||||||
|
* is generated.
|
||||||
|
*
|
||||||
|
* @return The x value of this {@link Chunk}
|
||||||
|
*/
|
||||||
|
public int getChunkX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the Z coordinate of the {@link Chunk} in which the {@link GEOResource}
|
||||||
|
* is generated.
|
||||||
|
*
|
||||||
|
* @return The z value of this {@link Chunk}
|
||||||
|
*/
|
||||||
|
public int getChunkZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the {@link Environment} in which the resource is generated.
|
||||||
|
* It is equivalent to {@link World#getEnvironment()}.
|
||||||
|
*
|
||||||
|
* @return The {@link Environment} of this generation
|
||||||
|
*/
|
||||||
|
public Environment getEnvironment() {
|
||||||
|
return world.getEnvironment();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link Biome} at the {@link Location} at which the {@link GEOResource} is
|
||||||
|
* generated.
|
||||||
|
*
|
||||||
|
* @return The {@link Biome} of this generation
|
||||||
|
*/
|
||||||
|
public Biome getBiome() {
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -37,10 +37,20 @@ public class MultiBlockInteractEvent extends Event implements Cancellable {
|
|||||||
this.clickedBlock = clicked;
|
this.clickedBlock = clicked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This returns the {@link Player} who interacted with our {@link MultiBlock}
|
||||||
|
*
|
||||||
|
* @return The {@link Player} who interacted with the {@link MultiBlock}
|
||||||
|
*/
|
||||||
public Player getPlayer() {
|
public Player getPlayer() {
|
||||||
return this.player;
|
return this.player;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the {@link MultiBlock} which was interacted with.
|
||||||
|
*
|
||||||
|
* @return The {@link MultiBlock} of this {@link MultiBlockInteractEvent}
|
||||||
|
*/
|
||||||
public MultiBlock getMultiBlock() {
|
public MultiBlock getMultiBlock() {
|
||||||
return this.multiBlock;
|
return this.multiBlock;
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import org.bukkit.block.Biome;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
import io.github.thebusybiscuit.slimefun4.core.services.localization.Language;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
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.GEOScanner;
|
||||||
@ -27,6 +28,7 @@ import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
|||||||
* @see ResourceManager
|
* @see ResourceManager
|
||||||
* @see GEOMiner
|
* @see GEOMiner
|
||||||
* @see GEOScanner
|
* @see GEOScanner
|
||||||
|
* @see GEOResourceGenerationEvent
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface GEOResource extends Keyed {
|
public interface GEOResource extends Keyed {
|
||||||
|
@ -3,6 +3,7 @@ package io.github.thebusybiscuit.slimefun4.api.geo;
|
|||||||
import java.util.OptionalInt;
|
import java.util.OptionalInt;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -11,6 +12,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
import io.github.thebusybiscuit.cscorelib2.config.Config;
|
||||||
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
import io.github.thebusybiscuit.cscorelib2.item.CustomItem;
|
||||||
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
import io.github.thebusybiscuit.cscorelib2.skull.SkullItem;
|
||||||
|
import io.github.thebusybiscuit.slimefun4.api.events.GEOResourceGenerationEvent;
|
||||||
import io.github.thebusybiscuit.slimefun4.implementation.items.geo.GEOMiner;
|
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.GEOScanner;
|
||||||
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
|
||||||
@ -75,6 +77,10 @@ public class ResourceManager {
|
|||||||
value += ThreadLocalRandom.current().nextInt(resource.getMaxDeviation());
|
value += ThreadLocalRandom.current().nextInt(resource.getMaxDeviation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GEOResourceGenerationEvent event = new GEOResourceGenerationEvent(world, block.getBiome(), x, z, resource, value);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
value = event.getValue();
|
||||||
|
|
||||||
setSupplies(resource, world, x, z, value);
|
setSupplies(resource, world, x, z, value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ package io.github.thebusybiscuit.slimefun4.core.attributes;
|
|||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
|
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNet;
|
||||||
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType;
|
||||||
|
import me.mrCookieSlime.Slimefun.SlimefunPlugin;
|
||||||
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,4 +37,33 @@ public interface EnergyNetComponent extends ItemAttribute {
|
|||||||
*/
|
*/
|
||||||
int getCapacity();
|
int getCapacity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is used for internal purposes to register the component.
|
||||||
|
* You do not have to call this method yourself.
|
||||||
|
*
|
||||||
|
* @param id
|
||||||
|
* The id of the {@link SlimefunItem} this refers to
|
||||||
|
*/
|
||||||
|
default void registerComponent(String id) {
|
||||||
|
switch (getEnergyComponentType()) {
|
||||||
|
case CONSUMER:
|
||||||
|
SlimefunPlugin.getRegistry().getEnergyConsumers().add(id);
|
||||||
|
break;
|
||||||
|
case CAPACITOR:
|
||||||
|
SlimefunPlugin.getRegistry().getEnergyCapacitors().add(id);
|
||||||
|
break;
|
||||||
|
case GENERATOR:
|
||||||
|
SlimefunPlugin.getRegistry().getEnergyGenerators().add(id);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int capacity = getCapacity();
|
||||||
|
|
||||||
|
if (capacity > 0) {
|
||||||
|
SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemFlag;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
import io.github.thebusybiscuit.cscorelib2.chat.ChatColors;
|
||||||
@ -135,8 +136,11 @@ public abstract class SlimefunLocalization extends Localization implements Keyed
|
|||||||
return new CustomItem(item, meta -> {
|
return new CustomItem(item, meta -> {
|
||||||
meta.setDisplayName(ChatColor.AQUA + config.getString(key.getNamespace() + "." + key.getKey() + ".name"));
|
meta.setDisplayName(ChatColor.AQUA + config.getString(key.getNamespace() + "." + key.getKey() + ".name"));
|
||||||
List<String> lore = config.getStringList(key.getNamespace() + "." + key.getKey() + ".lore");
|
List<String> lore = config.getStringList(key.getNamespace() + "." + key.getKey() + ".lore");
|
||||||
lore.replaceAll(str -> ChatColor.GRAY + str);
|
lore.replaceAll(line -> ChatColor.GRAY + line);
|
||||||
meta.setLore(lore);
|
meta.setLore(lore);
|
||||||
|
|
||||||
|
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||||
|
meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -464,7 +464,7 @@ public class ChestSlimefunGuide implements SlimefunGuideImplementation {
|
|||||||
Player p = profile.getPlayer();
|
Player p = profile.getPlayer();
|
||||||
if (p == null) return;
|
if (p == null) return;
|
||||||
|
|
||||||
ItemStack result = item.getRecipeOutput() != null ? item.getRecipeOutput() : item.getItem();
|
ItemStack result = item.getRecipeOutput();
|
||||||
RecipeType recipeType = item.getRecipeType();
|
RecipeType recipeType = item.getRecipeType();
|
||||||
ItemStack[] recipe = item.getRecipe();
|
ItemStack[] recipe = item.getRecipe();
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items;
|
package io.github.thebusybiscuit.slimefun4.implementation.items;
|
||||||
|
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
|
||||||
|
@ -70,7 +70,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
|
|
||||||
private boolean ticking = false;
|
private boolean ticking = false;
|
||||||
private BlockTicker blockTicker;
|
private BlockTicker blockTicker;
|
||||||
private GeneratorTicker energyTicker;
|
private GeneratorTicker generatorTicker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates a new {@link SlimefunItem} from the given arguments.
|
* This creates a new {@link SlimefunItem} from the given arguments.
|
||||||
@ -183,10 +183,21 @@ public class SlimefunItem implements Placeable {
|
|||||||
return recipeType;
|
return recipeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the result of crafting this {@link SlimefunItem}
|
||||||
|
*
|
||||||
|
* @return The recipe output of this {@link SlimefunItem}
|
||||||
|
*/
|
||||||
public ItemStack getRecipeOutput() {
|
public ItemStack getRecipeOutput() {
|
||||||
return recipeOutput;
|
return recipeOutput != null ? recipeOutput.clone() : item.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method returns the {@link Research} this {@link SlimefunItem} is linked to.
|
||||||
|
* This will be null if the item is not linked to any {@link Research}
|
||||||
|
*
|
||||||
|
* @return The linked {@link Research} or null
|
||||||
|
*/
|
||||||
public Research getResearch() {
|
public Research getResearch() {
|
||||||
return research;
|
return research;
|
||||||
}
|
}
|
||||||
@ -248,7 +259,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
|
|
||||||
// We should maybe refactor this and move it to a subclass
|
// We should maybe refactor this and move it to a subclass
|
||||||
public GeneratorTicker getEnergyTicker() {
|
public GeneratorTicker getEnergyTicker() {
|
||||||
return energyTicker;
|
return generatorTicker;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -285,7 +296,6 @@ public class SlimefunItem implements Placeable {
|
|||||||
preRegister();
|
preRegister();
|
||||||
|
|
||||||
SlimefunItem conflicting = getByID(id);
|
SlimefunItem conflicting = getByID(id);
|
||||||
|
|
||||||
if (conflicting != null) {
|
if (conflicting != null) {
|
||||||
throw new IdConflictException(this, conflicting);
|
throw new IdConflictException(this, conflicting);
|
||||||
}
|
}
|
||||||
@ -327,7 +337,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this instanceof EnergyNetComponent && !SlimefunPlugin.getRegistry().getEnergyCapacities().containsKey(getID())) {
|
if (this instanceof EnergyNetComponent && !SlimefunPlugin.getRegistry().getEnergyCapacities().containsKey(getID())) {
|
||||||
registerEnergyNetComponent((EnergyNetComponent) this);
|
((EnergyNetComponent) this).registerComponent(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) {
|
if (SlimefunPlugin.getItemCfg().getBoolean(id + ".enabled")) {
|
||||||
@ -345,19 +355,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
|
|
||||||
SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this);
|
SlimefunPlugin.getRegistry().getEnabledSlimefunItems().add(this);
|
||||||
SlimefunPlugin.getRegistry().getSlimefunItemIds().put(id, this);
|
SlimefunPlugin.getRegistry().getSlimefunItemIds().put(id, this);
|
||||||
|
loadItemHandlers();
|
||||||
for (ItemHandler handler : itemhandlers.values()) {
|
|
||||||
Optional<IncompatibleItemHandlerException> exception = handler.validate(this);
|
|
||||||
|
|
||||||
if (exception.isPresent()) {
|
|
||||||
throw exception.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!handler.isPrivate()) {
|
|
||||||
Set<ItemHandler> handlerset = getPublicItemHandlers(handler.getIdentifier());
|
|
||||||
handlerset.add(handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (this instanceof VanillaItem) {
|
else if (this instanceof VanillaItem) {
|
||||||
state = ItemState.VANILLA;
|
state = ItemState.VANILLA;
|
||||||
@ -373,25 +371,18 @@ public class SlimefunItem implements Placeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerEnergyNetComponent(EnergyNetComponent component) {
|
private void loadItemHandlers() {
|
||||||
switch (component.getEnergyComponentType()) {
|
for (ItemHandler handler : itemhandlers.values()) {
|
||||||
case CONSUMER:
|
Optional<IncompatibleItemHandlerException> exception = handler.validate(this);
|
||||||
SlimefunPlugin.getRegistry().getEnergyConsumers().add(id);
|
|
||||||
break;
|
if (exception.isPresent()) {
|
||||||
case CAPACITOR:
|
throw exception.get();
|
||||||
SlimefunPlugin.getRegistry().getEnergyCapacitors().add(id);
|
|
||||||
break;
|
|
||||||
case GENERATOR:
|
|
||||||
SlimefunPlugin.getRegistry().getEnergyGenerators().add(id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int capacity = component.getCapacity();
|
if (!handler.isPrivate()) {
|
||||||
|
Set<ItemHandler> handlerset = getPublicItemHandlers(handler.getIdentifier());
|
||||||
if (capacity > 0) {
|
handlerset.add(handler);
|
||||||
SlimefunPlugin.getRegistry().getEnergyCapacities().put(id, capacity);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,6 +395,10 @@ public class SlimefunItem implements Placeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setRecipe(ItemStack[] recipe) {
|
public void setRecipe(ItemStack[] recipe) {
|
||||||
|
if (recipe == null || recipe.length < 9) {
|
||||||
|
throw new IllegalArgumentException("Cannot set a recipe shorter than 9 elements.");
|
||||||
|
}
|
||||||
|
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -412,6 +407,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setCategory(Category category) {
|
public void setCategory(Category category) {
|
||||||
|
Validate.notNull(category, "'category' is not allowed to be null!");
|
||||||
this.category = category;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -482,8 +478,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
category.add(this);
|
category.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack output = recipeOutput == null ? item.clone() : recipeOutput.clone();
|
recipeType.register(recipe, getRecipeOutput());
|
||||||
recipeType.register(recipe, output);
|
|
||||||
}
|
}
|
||||||
catch (Exception x) {
|
catch (Exception x) {
|
||||||
error("Failed to properly load the Item \"" + id + "\"", x);
|
error("Failed to properly load the Item \"" + id + "\"", x);
|
||||||
@ -501,7 +496,7 @@ public class SlimefunItem implements Placeable {
|
|||||||
blockTicker = (BlockTicker) handler;
|
blockTicker = (BlockTicker) handler;
|
||||||
}
|
}
|
||||||
else if (handler instanceof GeneratorTicker) {
|
else if (handler instanceof GeneratorTicker) {
|
||||||
energyTicker = (GeneratorTicker) handler;
|
generatorTicker = (GeneratorTicker) handler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -525,10 +520,6 @@ public class SlimefunItem implements Placeable {
|
|||||||
// Useful for calls to Slimefun.getItemValue(...)
|
// Useful for calls to Slimefun.getItemValue(...)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setItem(ItemStack stack) {
|
|
||||||
this.item = stack;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method will assign the given wiki page to this Item.
|
* This method will assign the given wiki page to this Item.
|
||||||
* Note that you only need to provide the page name itself,
|
* Note that you only need to provide the page name itself,
|
||||||
|
Loading…
Reference in New Issue
Block a user