RuneHive-Game
Loading...
Searching...
No Matches
ClanShowcase.java
Go to the documentation of this file.
1package com.runehive.content.clanchannel.content;
2
3import com.runehive.content.clanchannel.channel.ClanChannel;
4import com.runehive.content.clanchannel.channel.ClanChannelHandler;
5import com.runehive.game.world.entity.mob.player.Player;
6import com.runehive.game.world.items.Item;
7import com.runehive.game.world.items.ItemDefinition;
8import com.runehive.net.packet.out.SendItemOnInterface;
9import com.runehive.net.packet.out.SendMessage;
10import com.runehive.net.packet.out.SendString;
11
12import java.util.ArrayList;
13import java.util.List;
14
15public class ClanShowcase {
16 private final ClanChannel channel;
17 public int[] showcase = new int[3];
18 public List<Integer> showcaseItems = new ArrayList<>(28);
19 private int currentItem = -1, currentSlot = -1;
20 private int showcaseSlot;
21
23 this.channel = channel;
24 }
25
26 public void openShowcase(Player player, int slot) {
27 Item[] showcase = new Item[28];
28 for (int index = 0; index < showcaseItems.size(); index++) {
29 showcase[index] = new Item(showcaseItems.get(index));
30 }
31 player.send(new SendString(channel.getName() + "'s Showcase", 57702));
32 player.send(new SendString(showcaseItems.size() + "/28", 57718));
33 player.send(new SendItemOnInterface(57716, showcase));
34 player.send(new SendItemOnInterface(57717));
36 currentSlot = -1;
37 currentItem = -1;
38 player.interfaceManager.open(57700);
39 }
40
41 public void select(Player player, int item, int slot) {
42 if (!player.interfaceManager.isInterfaceOpen(57700) || slot < 0 || slot >= showcaseItems.size())
43 return;
44
45 int id = showcaseItems.get(slot);
46 if (item == id) {
48 currentItem = id;
49 player.send(new SendItemOnInterface(57717, new Item(id)));
50 }
51 }
52
53 public void set(Player player) {
54 if (!player.interfaceManager.isInterfaceOpen(57700) || showcaseSlot < 0 || showcaseSlot >= 3)
55 return;
56
57 if (currentSlot == -1 || currentItem == -1) {
58 player.send(new SendMessage("You should select an item first."));
59 return;
60 }
61
64 Item[] showcase = new Item[28];
65 for (int index = 0; index < showcaseItems.size(); index++) {
66 showcase[index] = new Item(showcaseItems.get(index));
67 }
68 player.send(new SendItemOnInterface(57716));
69 player.send(new SendItemOnInterface(57716, showcase));
70 player.send(new SendMessage("You have successfully changed your showcase."));
71 }
72
73 public void remove(Player player) {
74 if (!player.interfaceManager.isInterfaceOpen(57700))
75 return;
76
77 if (currentSlot == -1 || currentItem == -1) {
78 player.send(new SendMessage("You should select an item first."));
79 return;
80 }
81
82 if (showcaseItems.size() <= 3) {
83 player.send(new SendMessage("You need a minimum of 3 showcase items. This action can not be performed."));
84 return;
85 }
86
87 player.dialogueFactory.sendStatement(
88 "Are you sure you want to delete <col=225>" + ItemDefinition.get(currentItem).getName() + "</col>?",
89 "Once this action is performed it can not be undone!")
90 .sendOption("Yes", () -> {
93 player.send(new SendMessage("You have successfully removed that item from your showcase."));
94 }, "Nevermind", () -> player.dialogueFactory.clear()).execute();
95 }
96}
void select(Player player, int item, int slot)
boolean isInterfaceOpen(int id)
Checks if a certain interface is enter.
void open(int identification)
Opens an interface for the player.
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.
The container class that represents an item that can be interacted with.
Definition Item.java:21
The OutgoingPacket that sends a message to a Players chatbox in the client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.