RuneHive-Game
Loading...
Searching...
No Matches
CoalBag.java
Go to the documentation of this file.
1package com.runehive.content.bags.impl;
2
3import com.runehive.content.bags.ItemBag;
4import com.runehive.game.world.entity.mob.player.Player;
5import com.runehive.game.world.items.Item;
6import com.runehive.game.world.items.ItemDefinition;
7import com.runehive.game.world.items.containers.ItemContainer;
8
9import java.util.Objects;
10import java.util.function.Predicate;
11
12public class CoalBag extends ItemBag {
13
14 public static final int SIZE = 27;
15
16 public CoalBag() {
18 }
19
20 @Override
21 public String getItem() {
22 return "coal";
23 }
24
25 @Override
26 public String getName() {
27 return "coal bag";
28 }
29
30 @Override
31 public Predicate<Item> isAllowed() {
32 return coal -> Objects.nonNull(coal) && (ItemDefinition.get(coal.getId()).getName().startsWith("Coal") && !ItemDefinition.get(coal.getId()).getName().contains("bag")) && !ItemDefinition.get(coal.getId()).isStackable();
33 }
34
35 @Override
36 public String getIndication() {
37 return "is";
38 }
39
40 @Override
41 public void check(Player player) {
42 if(container.getFreeSlots() == SIZE) {
43 player.message("The "+getName()+" is empty.");
44 return;
45 }
46
47 player.message("The "+getName()+" contains "+container.computeAmountForId(453)+" pieces of coal.");
48 }
49}
ItemBag(ItemContainer container)
Definition ItemBag.java:15
final ItemContainer container
Definition ItemBag.java:13
This class represents a character controlled by a player.
Definition Player.java:125
Represents all of an in-game Item's attributes.
static ItemDefinition get(int id)
Gets an item definition.
An abstraction game representing a group of Items.
An enumerated type defining policies for stackable Items.
NEVER
The NEVER policy, items are never stacked regardless of their ItemDefinition table.