forked from 2009Scape/Server
Implemented shared banks aka clan banks
Players can talk to a banker to enable clan banks. When enabled, any banking function will use the primary bank of the owner of the clan chat the player is in. This only works while the bank owner is online; if they are offline the player will fallback to their own bank.
This commit is contained in:
parent
dd35e479c1
commit
7b5ac708dc
3 changed files with 78 additions and 13 deletions
|
|
@ -45,18 +45,7 @@ class BankerDialogue(player: Player? = null) : core.game.dialogue.DialoguePlugin
|
|||
|
||||
2 -> showTopics(
|
||||
Topic(core.game.dialogue.FacialExpression.FRIENDLY, "I'd like to access my bank account, please.", 10),
|
||||
IfTopic(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"I'd like to switch to my ${getBankAccountName(player, true)} bank account.",
|
||||
13,
|
||||
hasActivatedSecondaryBankAccount(player)
|
||||
),
|
||||
IfTopic(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"I'd like to open a secondary bank account.",
|
||||
20,
|
||||
!hasActivatedSecondaryBankAccount(player)
|
||||
),
|
||||
Topic(core.game.dialogue.FacialExpression.FRIENDLY, "I'd like to switch my default bank account.", 7),
|
||||
Topic(core.game.dialogue.FacialExpression.FRIENDLY, "I'd like to check my PIN settings.", 11),
|
||||
Topic(core.game.dialogue.FacialExpression.FRIENDLY, "I'd like to collect items.", 12),
|
||||
Topic(core.game.dialogue.FacialExpression.ASKING, "What is this place?", 3),
|
||||
|
|
@ -78,6 +67,53 @@ class BankerDialogue(player: Player? = null) : core.game.dialogue.DialoguePlugin
|
|||
"Leave your valuables with us if you want to keep them safe."
|
||||
).also { stage = END_DIALOGUE }
|
||||
|
||||
7 -> showTopics(
|
||||
IfTopic(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"I'd like to turn on the Clan bank, please.",
|
||||
8,
|
||||
!(player.getAttribute("clanbank:enabled",false))
|
||||
),
|
||||
IfTopic(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"I'd like to turn off the Clan bank, please.",
|
||||
9,
|
||||
player.getAttribute("clanbank:enabled",false)
|
||||
),
|
||||
IfTopic(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"I'd like to switch to my ${getBankAccountName(player, true)} bank account.",
|
||||
13,
|
||||
hasActivatedSecondaryBankAccount(player)
|
||||
),
|
||||
IfTopic(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"I'd like to open a secondary bank account.",
|
||||
20,
|
||||
!hasActivatedSecondaryBankAccount(player)
|
||||
),
|
||||
)
|
||||
|
||||
8 -> {
|
||||
player.setAttribute("/save:clanbank:enabled", true)
|
||||
|
||||
npcl(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"The Clan bank has been enabled. " +
|
||||
"If the Clan owner is online, you will access their primary bank account instead of your own."
|
||||
).also { stage = 2 }
|
||||
}
|
||||
|
||||
9 -> {
|
||||
player.removeAttribute("clanbank:enabled")
|
||||
|
||||
npcl(
|
||||
core.game.dialogue.FacialExpression.FRIENDLY,
|
||||
"The Clan bank has been disabled. " +
|
||||
"You will now always open your personal bank account."
|
||||
).also { stage = 2 }
|
||||
}
|
||||
|
||||
10 -> {
|
||||
openBankAccount(player)
|
||||
end()
|
||||
|
|
|
|||
|
|
@ -43,6 +43,11 @@ public final class BankContainer extends Container {
|
|||
*/
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Snowscape. The player reference.
|
||||
*/
|
||||
private Player owner;
|
||||
|
||||
/**
|
||||
* The bank listener.
|
||||
*/
|
||||
|
|
@ -76,6 +81,7 @@ public final class BankContainer extends Container {
|
|||
super(SIZE, ContainerType.ALWAYS_STACK, SortType.HASH);
|
||||
super.register(listener = new BankListener(player));
|
||||
this.player = player;
|
||||
this.owner = player;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -110,6 +116,18 @@ public final class BankContainer extends Container {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Snowscape custom. Sets the current player. Used for clan banks.
|
||||
* @param newplayer The new player assigned to the bank.
|
||||
*/
|
||||
public void setPlayer(Player newPlayer) {
|
||||
// Only modify if the bank is not open, otherwise the player who is accessing it will suddenly be unable to deposit/withdraw
|
||||
if (!isOpen()) {
|
||||
this.player = newPlayer;
|
||||
this.listener.player = newPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Open the bank.
|
||||
*/
|
||||
|
|
@ -195,6 +213,8 @@ public final class BankContainer extends Container {
|
|||
player.getInterfaceManager().closeSingleTab();
|
||||
player.removeAttribute("search");
|
||||
player.getPacketDispatch().sendRunScript(571, "");
|
||||
//Snowscape. Set the player back to the owner of the account.
|
||||
setPlayer(this.owner);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1048,11 +1048,20 @@ public class Player extends Entity {
|
|||
return equipment;
|
||||
}
|
||||
|
||||
/**
|
||||
/** Snowscape modifications: Added check for clan bank
|
||||
* Gets the current active bank.
|
||||
* @return Current active bank.
|
||||
*/
|
||||
public BankContainer getBank() {
|
||||
if (getAttribute("clanbank:enabled",false)) {
|
||||
Player target = Repository.getPlayerByName(this.getCommunication().getCurrentClan());
|
||||
if (target != null) {
|
||||
target.getBankPrimary().setPlayer(this);
|
||||
return target.getBankPrimary();
|
||||
}
|
||||
}
|
||||
//The primary bank.player is changed back to the owner when a player closes it, but if something else, like dialogue, runs a getbank() function then it's never changed back. So this manually changes it when checking our own bank.
|
||||
bank.setPlayer(this);
|
||||
return useSecondaryBank ? bankSecondary : bank;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue