1package com.runehive.content.overrides;
3import com.runehive.game.world.entity.combat.attack.FightStyle;
4import com.runehive.game.world.entity.combat.attack.FightType;
5import com.runehive.game.world.entity.combat.weapon.WeaponInterface;
6import com.runehive.game.world.entity.mob.UpdateFlag;
7import com.runehive.game.world.entity.mob.player.Player;
8import com.runehive.game.world.items.Item;
9import com.runehive.game.world.items.containers.equipment.Equipment;
10import com.runehive.game.world.items.containers.equipment.EquipmentType;
11import com.runehive.game.world.position.Area;
12import com.runehive.net.packet.out.*;
24 public Map<String, OverridePreset>
presets =
new HashMap<>();
29 final Map<Integer, Integer>
buttons =
new HashMap<>();
38 player.message(
"You can't do this in the wilderness.");
72 for (
int i = 0; i <
presets.size(); i++) {
73 final var presetName =
presets.keySet().toArray()[i].toString();
88 final var item =
new Item(itemId);
89 final var canEquipItem = item.isEquipable();
91 player.dialogueFactory.sendItem(
"Keepsake Overrides",
"You can only keepsake equipable items.", itemId).execute();
96 player.dialogueFactory.sendItem(
"Keepsake Overrides",
"You cannot keepsake this item.", itemId).execute();
100 player.dialogueFactory.sendItem(
"Keepsake Overrides",
"You already have this as an override.", itemId).execute();
104 player.dialogueFactory.sendItem(
"Keepsake Overrides",
"You can only have 45 overrides.", itemId).execute();
108 player.message(
"You can't do this in the wilderness.");
112 player.dialogueFactory.sendStatement(
113 "Are you sure you want to keepsake the " + item.getName() +
"?",
"You will @red@not@bla@ be able to reclaim it.").sendOption(
114 "Yes, keepsake the " + item.getName(), () -> {
115 allOverrides.add(itemId);
116 player.inventory.remove(2399, 1);
117 player.inventory.remove(itemId, 1);
119 "Nevermind", () ->
player.dialogueFactory.clear()).execute();
124 player.message(
"Error deleting override.");
136 for (
int i = 0; i <
presets.size(); i++) {
138 if (Arrays.stream(
preset.items).anyMatch(presetItem -> presetItem !=
null && presetItem.getId() == item.
getId())) {
140 player.message(
"A preset has been deleted as it contained a deleted override.");
200 if (weaponIs2h && !overrideIs2h || overrideIs2h && !weaponIs2h) {
203 if (weaponIsRanged && !overrideIsRanged || overrideIsRanged && !weaponIsRanged) {
233 if (
presets.containsKey(presetName)) {
234 player.message(
"You already have a preset named " + presetName +
".");
245 if (!
presets.containsKey(presetName)) {
246 player.message(
"Error loading preset: " + presetName);
261 if (!
presets.containsKey(currentName)) {
262 player.message(
"Error renaming preset: " + currentName);
265 if (
presets.containsKey(newName)) {
266 player.message(
"You already have a preset named " + newName +
".");
272 player.message(
"Preset renamed to " + newName +
".");
277 if (!
presets.containsKey(presetName)) {
278 player.message(
"Error deleting preset: " + presetName);
283 player.message(
"Preset deleted.");
295 for (
int index = 0; index < oldTypes.length; index++) {
296 if (newTypes.length == index) {
302 result = newTypes[index];
306 if (oldTypes[index] ==
player.getCombat().getFightType()) {
309 if (newControlled != oldControlled) {
312 result = newTypes[index];
317 if (result ==
null) {
319 result = newTypes[newTypes.length - 1];
321 result = newTypes[1];
337 if (
buttons.containsKey(button)) {
364 player.message(
"You already have the maximum amount of presets saved.");
375 player.dialogueFactory.sendOption(
378 "What is manage mode?", () ->
player.dialogueFactory.sendStatement(
379 "Manage mode allows you to manage your overrides and presets.",
380 "When manage mode is on, clicking an override or preset will",
381 "open a menu allowing you to equip, delete, or rename it."),
383 "Nevermind", () ->
player.dialogueFactory.clear()).execute();
387 player.dialogueFactory.sendOption(
390 "@red@Delete " + item.
getName(), () ->
player.dialogueFactory.sendStatement(
391 "Are you sure you want to delete this override?",
"The item will be @red@permanently lost@bla@.").sendOption(
393 "Nevermind", () ->
player.dialogueFactory.clear()),
395 "Nevermind", () ->
player.dialogueFactory.clear()).execute();
399 player.dialogueFactory.sendOption(
400 "Equip <col=255>" + presetName +
"</col>", () ->
loadPreset(presetName),
402 "Rename preset", () -> {
403 player.dialogueFactory.clear();
407 "@red@Delete " + presetName, () ->
player.dialogueFactory.sendStatement(
408 "Are you sure you want to delete this preset?").sendOption(
409 "Yes, delete " + presetName, () ->
deletePreset(presetName),
410 "Nevermind", () ->
player.dialogueFactory.clear()),
412 "Nevermind", () ->
player.dialogueFactory.clear()).execute();
428 player.equipment.updateAnimation();
441 final var equipmentType = item.
getDefinition().getEquipmentType();
445 player.equipment.updateAnimation();
458 final var configValue = toggle.equals(
"on") ? 0 : 1;
460 return switch (equipmentSlot) {
461 case HAT, HELM, MASK, FACE ->
new SendConfig(1300, configValue);
462 case CAPE ->
new SendConfig(1301, configValue);
463 case AMULET ->
new SendConfig(1302, configValue);
464 case WEAPON ->
new SendConfig(1303, configValue);
465 case BODY, TORSO ->
new SendConfig(1304, configValue);
466 case SHIELD ->
new SendConfig(1305, configValue);
467 case LEGS ->
new SendConfig(1306, configValue);
468 case BOOTS ->
new SendConfig(1307, configValue);
469 case GLOVES ->
new SendConfig(1308, configValue);
476 return switch (equipmentSlot) {
void manageModeDialogue()
final int OVERRIDE_INTERFACE
void deletePreset(String presetName)
List< Integer > allOverrides
final int INFO_GO_BACK_BTN
void addOverride(int itemId)
Map< String, OverridePreset > presets
final int SHIELD_SLOT_BTN
int determineContainer(int itemId)
final int WEAPON_SLOT_BTN
boolean managingOverrides
void removeOverride(int itemId)
void renamePreset(String currentName, String newName)
final int GLOVES_SLOT_BTN
void managePresetDialogue(String presetName)
final Map< Integer, String > presetButtons
final int AMULET_SLOT_BTN
void removeAllOverrides()
boolean hasWeaponOverride()
final int SHIELD_CONTAINER
boolean handleButtons(int button)
final int SAVE_PRESET_BTN
final int AMULET_CONTAINER
final int VIEW_PRESET_BTN
final int WEAPON_CONTAINER
final Map< Integer, Integer > buttons
void manageItemDialogue(Item item)
record OverridePreset(Item... items)
void deleteOverride(Item item)
void setFilter(EquipmentType equipmentType, String name)
Map< Integer, Item > currentOverrides
final int GLOVES_CONTAINER
void equipOverride(Item item)
SendConfig toggleConfig(int itemId, String toggle)
FightType getFightType(Item item)
final int OPEN_OVERRIDE_BTN
final int BOOTS_CONTAINER
void createPreset(String presetName)
boolean hasShieldOverride()
void loadPreset(String presetName)
boolean hasOverride(int slot)
This class represents a character controlled by a player.
The container class that represents an item that can be interacted with.
final int getId()
Gets the identification of this item.
ItemDefinition getDefinition()
Gets the item definition for the item identifier.
WeaponInterface getWeaponInterface()
The container that manages the equipment for a player.
static final int WEAPON_SLOT
static final int SHIELD_SLOT
Handles checking if mobs are in a certain area.
static boolean inDuelArena(Interactable entity)
static boolean inWilderness(Position position)
The OutgoingPacket responsible for changing settings on a client.
The OutgoingPacket that sends a string to a Players itemcontainer in the client.
The enumerated type whose elements represent the fighting styles.
The enumerated type whose elements represent the fighting types.
final FightStyle getStyle()
Gets the style active when this type is active.
The enumerated type whose elements represent the weapon interfaces.
final FightType[] getFightTypes()
Gets the fight types that correspond with this interface.
The enumerated types of a players equipped item slots.