RuneHive-Tarnish
Neural OSRS Enhancement Framework
Loading...
Searching...
No Matches
ClanShowcaseBox.java
1
package
com.osroyale.content.itemaction.impl;
2
3
import
com.osroyale.content.clanchannel.ClanUtility;
4
import
com.osroyale.content.clanchannel.channel.ClanChannel;
5
import
com.osroyale.content.clanchannel.content.ClanLevel;
6
import
com.osroyale.content.itemaction.ItemAction;
7
import
com.osroyale.game.world.entity.mob.player.Player;
8
import
com.osroyale.game.world.items.Item;
9
import
com.osroyale.net.packet.out.SendMessage;
10
import
com.osroyale.util.Utility;
11
12
import
java.util.ArrayList;
13
import
java.util.List;
14
37
38
public
class
ClanShowcaseBox
extends
ItemAction
{
39
40
@Override
41
public
String
name
() {
42
return
"Clan Showcase Box"
;
43
}
44
45
@Override
46
public
boolean
inventory
(
Player
player, Item item,
int
opcode) {
47
if
(opcode != 1) {
48
return
false
;
49
}
50
ClanChannel
channel = player.clanChannel;
51
if
(channel ==
null
) {
52
player.send(
new
SendMessage
(
"You need to be in a clan to do this!"
));
53
return
true
;
54
}
55
if
(channel.getShowcase().showcaseItems.size() >= 28) {
56
player.send(
new
SendMessage
(
"You have reached the maximum capacity of showcase items you can hold. Please delete an item to proceed."
));
57
return
true
;
58
}
59
ClanLevel
level = channel.getDetails().level;
60
List<Item> items =
new
ArrayList<>();
61
62
for
(
int
reward :
ClanUtility
.
getRewardItems
(level)) {
63
Item rewardItem =
new
Item(reward, 1);
64
for
(Item showcase : channel.getShowcaseItems()) {
65
if
(rewardItem.getId() != showcase.getId())
66
items.add(rewardItem);
67
}
68
}
69
70
if
(items.isEmpty()) {
71
return
true
;
72
}
73
74
Item showcaseReward =
Utility
.
randomElement
(items);
75
player.inventory.
remove
(item);
76
channel.getShowcase().showcaseItems.add(showcaseReward.getId());
77
channel.
message
(
"We just received "
+ showcaseReward.getName() +
" from the showcase box!"
);
78
return
true
;
79
}
80
}
com.osroyale.content.clanchannel.ClanUtility
Definition
ClanUtility.java:45
com.osroyale.content.clanchannel.ClanUtility.getRewardItems
static int[] getRewardItems(ClanLevel level)
Definition
ClanUtility.java:62
com.osroyale.content.clanchannel.channel.ClanChannel
Definition
ClanChannel.java:71
com.osroyale.content.clanchannel.channel.ClanChannel.message
void message(Object... messages)
Definition
ClanChannel.java:435
com.osroyale.content.itemaction.ItemAction
Definition
ItemAction.java:42
com.osroyale.content.itemaction.impl.ClanShowcaseBox
Definition
ClanShowcaseBox.java:38
com.osroyale.content.itemaction.impl.ClanShowcaseBox.name
String name()
Definition
ClanShowcaseBox.java:41
com.osroyale.content.itemaction.impl.ClanShowcaseBox.inventory
boolean inventory(Player player, Item item, int opcode)
Definition
ClanShowcaseBox.java:46
com.osroyale.game.world.entity.mob.player.Player
Definition
Player.java:162
com.osroyale.game.world.items.containers.ItemContainer.remove
boolean remove(Item item)
Definition
ItemContainer.java:348
com.osroyale.net.packet.out.SendMessage
Definition
SendMessage.java:38
com.osroyale.util.Utility
Definition
Utility.java:64
com.osroyale.util.Utility.randomElement
static< T > T randomElement(Collection< T > collection)
Definition
Utility.java:285
com.osroyale.content.clanchannel.content.ClanLevel
Definition
ClanLevel.java:46