Rewrote or refactored many interfaces, fixing many small bugs

This commit is contained in:
Player Name
2025-07-15 11:56:19 +00:00
committed by Ryan
parent 7cf5049687
commit 264c2aa550
49 changed files with 796 additions and 1523 deletions
+1 -1
View File
@@ -1918,7 +1918,7 @@ fun runTask(entity: Entity, delay: Int = 0, repeatTimes: Int = 1, task: () -> Un
entity.pulseManager.run(object : Pulse(delay) {
override fun pulse(): Boolean {
task.invoke()
return --cycles == 0
return --cycles <= 0
}
})
}
-21
View File
@@ -1544,27 +1544,6 @@ public class ItemDefinition extends Definition<Item> {
*/
private static final String[] BONUS_NAMES = { "Stab: ", "Slash: ", "Crush: ", "Magic: ", "Ranged: ", "Stab: ", "Slash: ", "Crush: ", "Magic: ", "Ranged: ", "Summoning: ", "Strength: ", "Prayer: " };
/**
* Updates the equipment stats interface.
* @param player The player to update for.
*/
public static void statsUpdate(Player player) {
if (!player.getAttribute("equip_stats_open", false)) {
return;
}
int index = 0;
int[] bonuses = player.getProperties().getBonuses();
for (int i = 36; i < 50; i++) {
if (i == 47) {
continue;
}
int bonus = bonuses[index];
String bonusValue = bonus > -1 ? ("+" + bonus) : Integer.toString(bonus);
player.getPacketDispatch().sendString(BONUS_NAMES[index++] + bonusValue, 667, i);
}
player.getPacketDispatch().sendString("Attack bonus", 667, 34);
}
/**
* Checks if it has a plugin.
* @return {@code True} if so.
@@ -16,6 +16,7 @@ import core.plugin.Plugin;
import org.jetbrains.annotations.Nullable;
import core.game.interaction.InteractionListeners;
import core.game.system.config.ItemConfigParser;
import org.rs09.consts.Components;
import java.util.ArrayList;
@@ -303,11 +304,11 @@ public final class EquipmentContainer extends Container {
player.removeAttribute("dfs_spec");
player.getProperties().getCombatPulse().setHandler(null);
if (!player.getSettings().isSpecialToggled()) {
setVarp(player, 301, 0);
setVarp(player, 301, 0);
}
}
player.getAppearance().setAnimations();
player.updateAppearance();
player.updateAppearance();
player.getSettings().updateWeight();
updateBonuses(player);
}
@@ -349,7 +350,9 @@ public final class EquipmentContainer extends Container {
bonuses[10] += increase;
}
player.getProperties().setBonuses(bonuses);
update(player);
if (player.getInterfaceManager().hasMainComponent(Components.EQUIP_SCREEN2_667)) {
update(player);
}
}
/**
@@ -357,9 +360,6 @@ public final class EquipmentContainer extends Container {
* @param player The player to update for.
*/
public static void update(Player player) {
if (!player.getInterfaceManager().hasMainComponent(667)) {
return;
}
int index = 0;
int[] bonuses = player.getProperties().getBonuses();
for (int i = 36; i < 50; i++) {
@@ -370,6 +370,7 @@ public final class EquipmentContainer extends Container {
String bonusValue = bonus > -1 ? ("+" + bonus) : Integer.toString(bonus);
player.getPacketDispatch().sendString(BONUS_NAMES[index++] + bonusValue, 667, i);
}
player.getSettings().updateWeight();
player.getPacketDispatch().sendString("Attack bonus", 667, 34);
}
}
@@ -1,6 +1,5 @@
package core.game.node.entity.player.info.login;
import core.game.component.CloseEvent;
import core.game.component.Component;
import core.game.node.entity.player.Player;
import core.game.node.entity.player.link.emote.Emotes;
@@ -48,22 +47,17 @@ public final class LoginConfiguration {
*/
private static final Component LOBBY_PANE = new Component(549);
/**
* The lobby interface component.
*/
private static final Component LOBBY_INTERFACE = new Component(378);
/**
* The lobby message of the week models & constant to be set for auto selecting the models
*/
private static final int[] MESSAGE_MODEL = {15, 16, 17, 18, 19, 20, 21, 22, 23, 405, 447, 622, 623, 679, 715, 800};
private static int messModel;
/**
* The lobby interface close event.
*/
private static final Component LOBBY_INTERFACE = new Component(378).setCloseEvent(new CloseEvent() {
@Override
public boolean close(Player player, Component c) {
return player.getLocks().isLocked("login");
}
});
/**
* Constructs a new {@Code LoginConfiguration} {@Code Object}
*/
@@ -102,25 +96,25 @@ public final class LoginConfiguration {
}
}
Repository.getLobbyPlayers().add(player);
player.getPacketDispatch().sendString(getLastLogin(player), 378, 116);
player.getPacketDispatch().sendString("Welcome to " + GameWorld.getSettings().getName(), 378, 115);
player.getPacketDispatch().sendString(" ", 378, 37);
player.getPacketDispatch().sendString("Want to stay up to date with the latest news and updates? Join our <br>discord by using the link below!", 378, 38);
player.getPacketDispatch().sendString(" ", 378, 39);
player.getPacketDispatch().sendString("Discord Invite", 378, 14);
player.getPacketDispatch().sendString("Discord Invite", 378, 129);
player.getPacketDispatch().sendString("Credits", 378, 94);
player.getPacketDispatch().sendString(player.getDetails().getCredits() + "", 378, 96);
player.getPacketDispatch().sendString(" ", 378, 229);
player.getPacketDispatch().sendString("Want to contribute to " + ServerConstants.SERVER_NAME + "? <br>Visit the GitLab using the link below!", 378, 230);
player.getPacketDispatch().sendString(" ", 378, 231);
player.getPacketDispatch().sendString("Github", 378, 240);
player.getPacketDispatch().sendString(GameWorld.getSettings().getMessage_string(), messModel, getMessageChild(messModel));
player.getPacketDispatch().sendString("You can gain more credits by voting, reporting bugs and various other methods of contribution.", 378, 93);
setInterfaceText(player, "Welcome to " + ServerConstants.SERVER_NAME, 378, 115);
setInterfaceText(player, getLastLogin(player), 378, 116);
setInterfaceText(player, "", 378, 37);
setInterfaceText(player, "Want to stay up to date with the latest news and updates? Join our discord by using the link on our website!", 378, 38);
setInterfaceText(player, "", 378, 39);
setInterfaceText(player, "Discord Invite", 378, 14);
setInterfaceText(player, "Discord Invite", 378, 129);
setInterfaceText(player, "You can gain more credits by reporting bugs and various other methods of contribution.", 378, 93);
setInterfaceText(player, player.getDetails().getCredits() + "", 378, 96);
setInterfaceText(player, "Credits", 378, 94);
setInterfaceText(player, "", 378, 229);
setInterfaceText(player, "Want to contribute to " + ServerConstants.SERVER_NAME + "? Visit the GitLab using the link on our website!", 378, 230);
setInterfaceText(player, "", 378, 231);
setInterfaceText(player, "Github", 378, 240);
setInterfaceText(player, GameWorld.getSettings().getMessage_string(), messModel, getMessageChild(messModel));
player.getInterfaceManager().openWindowsPane(LOBBY_PANE);
player.getInterfaceManager().setOpened(LOBBY_INTERFACE);
PacketRepository.send(Interface.class, new InterfaceContext(player, 549, 2, 378, true));
PacketRepository.send(Interface.class, new InterfaceContext(player, 549, 3, messModel, true));//UPDATE `configs` SET `value`=FLOOR(RAND()*(25-10)+10) WHERE key_="messageInterface"
PacketRepository.send(Interface.class, new InterfaceContext(player, LOBBY_PANE.getId(), 2, 378, true));
PacketRepository.send(Interface.class, new InterfaceContext(player, LOBBY_PANE.getId(), 3, messModel, true));//UPDATE `configs` SET `value`=FLOOR(RAND()*(25-10)+10) WHERE key_="messageInterface"
player.getDetails().setLastLogin(System.currentTimeMillis());
}
@@ -168,12 +162,11 @@ public final class LoginConfiguration {
// 1050 is checked client-side for making piety/chivalry disallowed sfx, likely due to the minigame requirement.
// Set it here unconditionally until the minigame is implemented.
setVarbit(player, 3909, 8, false);
if (hasRequirement(player, Quests.KINGS_RANSOM, false)) {
setVarbit(player, 3909, 8, false);
}
if(ServerConstants.RULES_AND_INFO_ENABLED)
RulesAndInfo.openFor(player);
/*if (GameWorld.getSettings().isPvp()) {
player.getPacketDispatch().sendString("", 226, 1);
}*/
/*if (TutorialSession.getExtension(player).getStage() != 73) {
TutorialStage.load(player, TutorialSession.getExtension(player).getStage(), true);
}*/
@@ -206,21 +199,14 @@ public final class LoginConfiguration {
* @param player the player. Fullscreen mode Object id:
*/
public static final void welcome(final Player player) {
if (GameWorld.getSettings().isPvp()) {
player.getPacketDispatch().sendString("", 226, 0);
}
if (player.isArtificial()) {
return;
}
player.getPacketDispatch().sendMessage("Welcome to " + GameWorld.getSettings().getName() + ".");
//player.getPacketDispatch().sendMessage("You are currently playing in beta version 1.2");
player.getPacketDispatch().sendMessage("Welcome to " + ServerConstants.SERVER_NAME + ".");
if (player.getDetails().isMuted()) {
player.getPacketDispatch().sendMessage("You are muted.");
player.getPacketDispatch().sendMessage("To prevent further mutes please read the rules.");
}
// ResourceAIPManager.get().load(player);
// ResourceAIPManager.get().save(player);
}
/**
@@ -240,7 +226,8 @@ public final class LoginConfiguration {
player.getPacketDispatch().sendRunEnergy();
player.getFamiliarManager().login();
player.getInterfaceManager().openDefaultTabs();
player.getPacketDispatch().sendString("Friends List - World " + GameWorld.getSettings().getWorldId(), 550, 3);
setInterfaceText(player, "Friends List - " + ServerConstants.SERVER_NAME + " " + GameWorld.getSettings().getWorldId(), 550, 3);
setInterfaceText(player, "When you have finished playing " + ServerConstants.SERVER_NAME + ", always use the button below to logout safely.", 182, 0);
player.getQuestRepository().syncronizeTab(player);
player.getInterfaceManager().close();
player.getEmoteManager().refresh();
@@ -260,11 +247,11 @@ public final class LoginConfiguration {
return 8;
} else if (interfaceId == 16) {
return 6;
} else if (interfaceId == 17 || interfaceId == 15 || interfaceId == 18 || interfaceId == 19 || interfaceId == 21 || interfaceId == 22 || interfaceId == 447 || interfaceId == 405) {
return 4;
} else if (interfaceId == 20 || interfaceId == 623) {
return 5;
} else if (interfaceId == 23 || interfaceId == 800) {
} else if (interfaceId == 15 || interfaceId == 18 || interfaceId == 19 || interfaceId == 21 || interfaceId == 22 || interfaceId == 447 || interfaceId == 405) {
return 4;
} else if (interfaceId == 17 || interfaceId == 23 || interfaceId == 800) {
return 3;
} else if (interfaceId == 715) {
return 2;
@@ -289,12 +276,8 @@ public final class LoginConfiguration {
* @return the last login.
*/
public static String getLastLogin(Player player) {
String lastIp = player.getDetails().accountInfo.getLastUsedIp();
if (lastIp.equals("")) {
lastIp = player.getDetails().getIpAddress();
}
player.getDetails().accountInfo.setLastUsedIp(player.getDetails().getIpAddress());
String string = "You last logged in @timeAgo from: " + lastIp;
player.getPacketDispatch().sendLastLoginInfo();
String string = "You last logged in @timeAgo from:";
long time = player.getDetails().getLastLogin();
Date lastLogin = new Date(time);
Date current = new Date();
@@ -3,7 +3,6 @@ package core.game.node.entity.player.link;
import core.game.node.entity.player.Player;
import core.game.node.scenery.Scenery;
import core.tools.Log;
import core.tools.SystemLogger;
import core.game.system.task.Pulse;
import core.game.world.GameWorld;
import core.game.world.map.Location;
@@ -431,8 +430,11 @@ public final class PacketDispatch {
PacketRepository.send(CSConfigPacket.class, new CSConfigContext(player, id, value, type, params));
}
public void resetInterface(int id)
{
public void resetInterface(int id) {
PacketRepository.send(ResetInterface.class, new InterfaceContext(player, 0, 0, id, false));
}
public void sendLastLoginInfo() {
PacketRepository.send(LastLoginInfo.class, new PlayerContext(player));
}
}
@@ -4,9 +4,11 @@ import core.game.component.Component;
import core.game.node.entity.combat.spell.MagicSpell;
import core.game.node.entity.player.Player;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import static core.api.ContentAPIKt.setVarbit;
/**
* Represents a managing class of a players spell book.
@@ -15,7 +17,7 @@ import java.util.Map;
public final class SpellBookManager {
/**
* Represents the current interface if of the spellbook.
* Represents the current interface if of the spell book.
*/
private int spellBook = SpellBook.MODERN.getInterfaceId();
@@ -23,25 +25,26 @@ public final class SpellBookManager {
* Constructs a new {@code SpellBookManager} {@code Object}.
*/
public SpellBookManager() {
/**
/*
* empty.
*/
}
/**
* Sets the spell book.
* @param book
* @param book the spell book.
*/
public void setSpellBook(SpellBook book) {
this.spellBook = book.getInterfaceId();
}
/**
* Updates the
* @param player
* Updates the spell book.
* @param player the player.
*/
public void update(Player player) {
player.getInterfaceManager().openTab(new Component(SpellBook.forInterface(this.spellBook).getInterfaceId()));
player.getInterfaceManager().openTab(new Component(spellBook));
setVarbit(player, 357, Objects.requireNonNull(SpellBook.forInterface(spellBook)).ordinal());
}
/**
@@ -53,7 +56,7 @@ public final class SpellBookManager {
}
/**
* Represents a characters spellbook.
* Represents a characters spell book.
* @author 'Vexia
* @author Emperor
*/
@@ -298,7 +298,7 @@ public enum Emotes {
}
/**
* Handles the reward button for an emote.
* Handles the button for an emote.
*
* @param player the player.
* @param buttonId the button id.
@@ -1,5 +1,6 @@
package core.game.node.entity.player.link.prayer;
import content.data.Quests;
import core.game.node.entity.player.link.diary.DiaryType;
import core.game.node.entity.skill.SkillBonus;
import core.game.node.entity.skill.Skills;
@@ -221,11 +222,20 @@ public enum PrayerType {
* @return <code>True</code> if it is permitted.
*/
public boolean permitted(final Player player) {
if (player.getSkills().getStaticLevel(Skills.PRAYER) < getLevel() || player.getSkills().getStaticLevel(Skills.DEFENCE) < defenceReq) {
playAudio(player, Sounds.PRAYER_OFF_2673);
player.getDialogueInterpreter().sendDialogue("You need a <col=08088A>Prayer level of " + getLevel() + (player.getSkills().getStaticLevel(Skills.DEFENCE) < defenceReq ? (" and a Defence level of " + defenceReq) : "") + " to use " + StringUtils.formatDisplayName(name().toLowerCase().replace("_", " ")) + ".");
if (!hasLevelStat(player, Skills.PRAYER, level) || !hasLevelStat(player, Skills.DEFENCE, defenceReq)) {
sendDialogue(player, "You need a <col=08088A>" + (!hasLevelStat(player, Skills.PRAYER, level) ? "Prayer level of " + level + (!hasLevelStat(player, Skills.DEFENCE, defenceReq) ? " and a " : "") : "") + (!hasLevelStat(player, Skills.DEFENCE, defenceReq) ? "Defence level of " + defenceReq : "") + " to use " + StringUtils.formatDisplayName(name().toLowerCase().replace("_", " ")) + ".");
return false;
}
if (defenceReq == 65 || defenceReq == 70) {
if (!hasRequirement(player, Quests.KINGS_RANSOM)) {
return false;
} else {
if (getVarbit(player, 3909) != 8) {
setVarbit(player, 3909, 8, false);
}
}
}
return true;
}
@@ -241,17 +251,12 @@ public enum PrayerType {
player.getPrayer().getActive().add(this);
iconify(player, getIcon(player, this));
playAudio(player, sound.id);
if (this == PrayerType.PIETY
&& new ZoneBorders(2732, 3467, 2739, 3471, 0).insideBorder(player)) {
player.getAchievementDiaryManager().finishTask(player, DiaryType.SEERS_VILLAGE, 2, 3);
}
player.dispatch (new PrayerActivatedEvent(this));
player.dispatch (new PrayerActivatedEvent(this));
} else {
player.getPrayer().getActive().remove(this);
playAudio(player, Sounds.CANCEL_PRAYER_2663);
findNextIcon(player);
player.dispatch (new PrayerDeactivatedEvent(this));
player.dispatch (new PrayerDeactivatedEvent(this));
}
return true;
}
@@ -88,17 +88,16 @@ class GameSettings
/**"Lobby" interface
* The message of the week models to display
* 15 & 22 = keys & lock || 16 = fly swat || 17 = person with question marks || 18 & 447 = wise old man
* 19 = man & woman with mouth closed || 20 = man & lock & key || 21 = closed chests
* 23 = snowmen || 405 = Construction houses || 622 = Two sets of 3 people range, mage, melee
* 623 = Woodcutting || 679 = Summoning || 715 = Easter || 800 = Halloween
* Any value that isn't one listed above = random selection
* 15 & 22 = Lock w/key & keys || 16 = Fly swatters || 17 = Man & woman with question marks
* 18 & 447 = Wise old man & woman || 19 = Man with mouth zipped & woman talking || 20 = Man & lock w/key
* 21 = Chests that open & close || 23 = Christmas || 405 = Construction houses
* 622 = Two sets 3 people range, mage, melee 623 = Woodcutting || 679 = Summoning || 715 = Easter || 800 = Halloween
*/
var message_model: Int,
/**"Lobby" interface
* The message of the week text
* The "child" for writing text to these interfaces is located inside of LoginConfiguration.java
* The "child" for writing text to these interfaces is located inside LoginConfiguration.java
* method: getMessageChild
*/
var message_string: String
@@ -75,9 +75,10 @@ public final class PacketRepository {
OUTGOING_PACKETS.put(InstancedLocationUpdate.class, new InstancedLocationUpdate()); //
OUTGOING_PACKETS.put(CSConfigPacket.class, new CSConfigPacket()); //
OUTGOING_PACKETS.put(Varbit.class, new Varbit());
OUTGOING_PACKETS.put(ResetInterface.class, new ResetInterface());
OUTGOING_PACKETS.put(ResetInterface.class, new ResetInterface());
OUTGOING_PACKETS.put(VarcUpdate.class, new VarcUpdate());
OUTGOING_PACKETS.put(InterfaceSetAngle.class, new InterfaceSetAngle());
OUTGOING_PACKETS.put(LastLoginInfo.class, new LastLoginInfo());
}
/**
@@ -105,5 +106,4 @@ public final class PacketRepository {
}
}
}
}
}
@@ -0,0 +1,15 @@
package core.net.packet.out
import core.net.packet.IoBuffer
import core.net.packet.OutgoingPacket
import core.net.packet.context.PlayerContext
import java.net.Inet4Address
class LastLoginInfo : OutgoingPacket<PlayerContext> {
override fun send(context: PlayerContext) {
val buffer = IoBuffer(164)
buffer.imp4(Inet4Address.getByName(context.player.details.ipAddress).hashCode())
buffer.cypherOpcode(context.player.session.isaacPair.output)
context.player.session.write(buffer)
}
}