1package com.runehive.content.preset;
3import com.runehive.Config;
4import com.runehive.content.achievement.AchievementHandler;
5import com.runehive.content.achievement.AchievementKey;
6import com.runehive.content.dialogue.DialogueFactory;
7import com.runehive.game.world.entity.combat.magic.Autocast;
8import com.runehive.game.world.entity.mob.UpdateFlag;
9import com.runehive.game.world.entity.mob.player.Player;
10import com.runehive.game.world.entity.mob.player.PlayerRight;
11import com.runehive.game.world.entity.mob.prayer.Prayer;
12import com.runehive.game.world.entity.mob.prayer.PrayerBook;
13import com.runehive.game.world.entity.skill.Skill;
14import com.runehive.game.world.items.Item;
15import com.runehive.net.packet.out.SendItemOnInterface;
16import com.runehive.net.packet.out.SendMessage;
17import com.runehive.net.packet.out.SendString;
19import java.util.ArrayList;
30 public static final int SIZE = 10;
63 player.dialogueFactory.sendStatement(
"You need to be a donator for more preset slots!").execute();
67 player.attributes.set(
"PRELOADING_SLOT_KEY",
slot);
69 player.interfaceManager.open(57_000);
77 for (
int i = 0; i <
SIZE; i++) {
79 String defaultName = locked ?
"<col=F23030>Locked" : (
preset[i] ==
null ?
"---" :
preset[i].getName());
80 String
name = (i ==
slot ?
"<col=ffffff>" :
"<col=39BF5B>") + defaultName;
102 player.send(
new SendString(
"<col=99E823>" + (prayers ?
"Not " :
"") +
"Set!", 57013));
114 player.dialogueFactory.sendStatement(
"You need to be a donator for more preset slots!").execute();
135 player.dialogueFactory.sendStatement(
"You need to be a donator for more preset slots!").execute();
140 player.dialogueFactory.sendStatement(
"Please name your preset before uploading your gear!").execute();
144 player.dialogueFactory.sendOption(
"Upload preset", () -> {
146 if (
player.quickPrayers !=
null) {
153 player.dialogueFactory.clear();
154 },
"Nevermind", () ->
player.dialogueFactory.clear()).execute();
170 player.bank.depositeInventory(
false);
171 player.bank.depositeEquipment(
false);
174 if (!
player.inventory.isEmpty() || !
player.equipment.isEmpty()) {
175 player.send(
new SendMessage(
"Please deposit all items from your inventory and equipment."));
187 player.inventory.refresh();
189 player.spellbook =
preset[
slot].getSpellbook();
194 player.playerAssistant.setValueIcon();
199 List<String> requirements =
new ArrayList<>();
205 requirements.add(item.getName());
209 int tabSlot =
player.bank.computeIndexForId(item.getId());
213 int tab =
player.bank.tabForSlot(tabSlot);
217 int amount =
player.bank.get(tabSlot).getAmount();
221 if (item.getAmount() > amount) {
223 item.setAmount(amount);
226 if (
player.bank.remove(item.unnoted(), tabSlot,
false)) {
227 if (!
player.bank.indexOccupied(tabSlot)) {
228 player.bank.changeTabAmount(tab, -1);
232 player.equipment.manualWear(item.copy());
236 if (!requirements.isEmpty()) {
237 player.send(
new SendMessage(
"<col=ff0000>Some items could not be equipped due to not having the skill requirements."));
243 for (
int index = 0; index <
inventory.length; index++) {
249 int tabSlot =
player.bank.computeIndexForId(item.
getId());
253 int tab =
player.bank.tabForSlot(tabSlot);
257 int amount =
player.bank.get(tabSlot).getAmount();
267 if (!
player.bank.indexOccupied(tabSlot)) {
268 player.bank.changeTabAmount(tab, -1);
272 player.inventory.set(index, item.
copy(),
false);
284 player.dialogueFactory.sendOption(
"Delete " +
preset[
slot].getName() +
" (<col=f44259>CANT BE UNDONE</col>)", () -> {
288 player.dialogueFactory.clear();
289 },
"Nevermind", () ->
player.dialogueFactory.clear()).execute();
295 factory.
sendOption(
"View current settings", () -> {
297 factory.
sendInformationBox(
"<col=3E74B8>Preset Settings",
"</col>Open on death: " + (
deathOpen ?
"<col=0E8716>Enabled" :
"<col=F01818>Disabled"),
"</col>Automatic deposit: " + (
autoDeposit ?
"<col=0E8716>Enabled" :
"<col=F01818>Disabled")).
execute();
299 },
"Toggle open on death", () -> factory.
onAction(() -> {
301 factory.
sendStatement(
"The preset interface will now " + (
deathOpen ?
"" :
"<col=F01818>not</col> ") +
"open on death",
"automatically.").
execute();
302 }),
"Toggle automatic deposit", () -> {
312 if (!
open && !
player.interfaceManager.isInterfaceOpen(57_000))
314 if (
player.getCombat().inCombat()) {
319 return !
player.positionChange;
325 for (
int i = 0; i <
SIZE; i++) {
335 return player.attributes.get(
"PRELOADING_SLOT_KEY", Integer.class);
339 for (
int i = 0; i < requirements.length; i++) {
340 int level =
player.skills.getMaxLevel(i);
341 int required = requirements[i];
343 if (level < required) {
The class that contains setting-related constants for the server.
static final int MAGIC_TAB
Handles the achievements.
static void activate(Player player, AchievementKey achievement)
Activates the achievement for the individual player.
Represents a factory class that contains important functions for building dialogues.
final DialogueFactory execute()
Retrieves the next dialogue in the chain and executes it.
final DialogueFactory onAction(Runnable action)
Sets an action so this action can be executed after dialogues are done.
final DialogueFactory sendInformationBox(String title, String...lines)
final DialogueFactory sendStatement(String... lines)
Appends a StatementDialogue to the current dialogue chain.
final DialogueFactory sendOption(String option1, Runnable action1, String option2, Runnable action2)
Appends the OptionDialogue onto the current dialogue chain.
void refresh()
Refreshes all the components on the interface.
void delete()
Handles deleting the preset.
PresetManager(Player player)
Constructs a new PresetManager.
void openSettings()
Handles opening the settings menu for the preset.
boolean permitted
If the player is allowed all presets.
void open(int slot)
Opens the preset to a specific slot.
final Player player
The player instance.
void upload()
Handles uploading the preset content.
int getSlot()
Gets the current slot of the preset.
boolean autoDeposit
The automatically deposit items on activate flag.
Preset[] preset
The presets.
boolean deathOpen
The preset opening on death flag.
void name(String name)
Handles naming the preset.
boolean hasItemRequirements(Player player, int[] requirements)
static final int SIZE
The total preset size.
void open()
Opens the preset to the last viewed slot.
boolean valid(boolean open)
Checks if the preset is valid.
void activate()
Activates the preset.
int getTaken()
Gets the taken preset amount.
void equipment(Preset preset)
void inventory(Preset preset)
static void reset(Player player)
This class represents a character controlled by a player.
A PrayerBook which stores prayers.
void only(Prayer... prayers)
Activates only the prayers provided.
Represents a trainable and usable skill.
static final int PRAYER
The prayer skill id.
static final int RANGED
The ranged skill id.
static final int DEFENCE
The defence skill id.
static final int MAGIC
The magic skill id.
static final int ATTACK
The attack skill id.
static final int STRENGTH
The strength skill id.
static final int HITPOINTS
The hitpoints skill id.
The container class that represents an item that can be interacted with.
final void setAmount(int amount)
Sets the quantity of this item.
final int getId()
Gets the identification of this item.
final int getAmount()
Gets the quantity of this item.
Item copy()
A substitute for Object#clone() that creates another 'copy' of this instance.
Item unnoted()
Gets the unnoted item.
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.
Holds all the player right data.
static int getPresetAmount(Player player)