From b2ad6d9712f07f329a9f9c341214d35a6ac4bcfe Mon Sep 17 00:00:00 2001 From: Ceikry Date: Sat, 18 Jun 2022 14:04:50 +0000 Subject: [PATCH] GE offer notification system now supports opt-in privacy to remove username from messages Opt-in to GE privacy with new in-game command ::geprivacy on Removed discord GE offer update notifications (only new buy/sell offers shown) Limited in-game GE notifications to player offers only --- .../src/main/kotlin/rs09/game/ge/GrandExchange.kt | 15 +++++++++++++-- .../kotlin/rs09/game/ge/GrandExchangeOffer.kt | 7 ++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt b/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt index 1c271c8d4..fb5584323 100644 --- a/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt +++ b/Server/src/main/kotlin/rs09/game/ge/GrandExchange.kt @@ -11,6 +11,7 @@ import rs09.game.system.SystemLogger import rs09.game.system.command.Privilege import rs09.game.system.config.ItemConfigParser import rs09.game.world.repository.Repository +import rs09.tools.stringtools.colorize import java.lang.Integer.max import java.sql.ResultSet @@ -102,6 +103,13 @@ class GrandExchange : StartupListener, Commands { PriceIndex.allowItem(id) notify(player, "Allowed ${getItemName(id)} for GE trade.") } + + define("geprivacy", Privilege.STANDARD) {player, _ -> + val current = getAttribute(player, "ge-exclude", false) + val new = !current + notify(player, "Your name is now ${if (new) colorize("%RHIDDEN") else colorize("%RSHOWN")}.") + setAttribute(player, "/save:ge-exclude", new) + } } companion object { @@ -253,8 +261,9 @@ class GrandExchange : StartupListener, Commands { offer.offerState = OfferState.REGISTERED //GrandExchangeRecords.getInstance(player).update(offer) - if (offer.sell) { - Repository.sendNews(player.username + " just offered " + offer.amount + " " + getItemName(offer.itemID) + " on the GE.") + if (offer.sell && !player.isArtificial) { + val username = if (getAttribute(player, "ge-exclude", false)) "?????" else player.username + Repository.sendNews(username + " just offered " + offer.amount + " " + getItemName(offer.itemID) + " on the GE.") } offer.writeNew() @@ -299,6 +308,7 @@ class GrandExchange : StartupListener, Commands { if(canUpdatePriceIndex(seller, buyer)) PriceIndex.addTrade(offer.itemID, amount, (totalCoinXC / amount)) +/* if (seller.amountLeft > 0) { Discord.postOfferUpdate(true, seller.itemID, seller.offeredValue, seller.amountLeft) } @@ -306,6 +316,7 @@ class GrandExchange : StartupListener, Commands { if (buyer.amountLeft > 0) { Discord.postOfferUpdate(false, buyer.itemID, buyer.offeredValue, buyer.amountLeft) } +*/ seller.update() val sellerPlayer = Repository.uid_map[seller.playerUID] diff --git a/Server/src/main/kotlin/rs09/game/ge/GrandExchangeOffer.kt b/Server/src/main/kotlin/rs09/game/ge/GrandExchangeOffer.kt index fca62b570..8f04a171d 100644 --- a/Server/src/main/kotlin/rs09/game/ge/GrandExchangeOffer.kt +++ b/Server/src/main/kotlin/rs09/game/ge/GrandExchangeOffer.kt @@ -1,5 +1,6 @@ package rs09.game.ge +import api.getAttribute import core.cache.def.impl.ItemDefinition import core.game.ge.OfferState import core.game.node.entity.player.Player @@ -144,7 +145,11 @@ class GrandExchangeOffer() { uid = nowuid.getLong(1) visualize(player) stmt.close() - Discord.postNewOffer(sell, itemID, offeredValue, amount, player?.username ?: "Unknown") + + val username = if (getAttribute(player!!, "ge-exclude", false)) "?????" + else player?.username ?: "?????" + + Discord.postNewOffer(sell, itemID, offeredValue, amount, username) } } }