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
This commit is contained in:
Ceikry 2022-06-18 14:04:50 +00:00 committed by Ryan
parent 6d12982b76
commit b2ad6d9712
2 changed files with 19 additions and 3 deletions

View file

@ -11,6 +11,7 @@ import rs09.game.system.SystemLogger
import rs09.game.system.command.Privilege import rs09.game.system.command.Privilege
import rs09.game.system.config.ItemConfigParser import rs09.game.system.config.ItemConfigParser
import rs09.game.world.repository.Repository import rs09.game.world.repository.Repository
import rs09.tools.stringtools.colorize
import java.lang.Integer.max import java.lang.Integer.max
import java.sql.ResultSet import java.sql.ResultSet
@ -102,6 +103,13 @@ class GrandExchange : StartupListener, Commands {
PriceIndex.allowItem(id) PriceIndex.allowItem(id)
notify(player, "Allowed ${getItemName(id)} for GE trade.") 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 { companion object {
@ -253,8 +261,9 @@ class GrandExchange : StartupListener, Commands {
offer.offerState = OfferState.REGISTERED offer.offerState = OfferState.REGISTERED
//GrandExchangeRecords.getInstance(player).update(offer) //GrandExchangeRecords.getInstance(player).update(offer)
if (offer.sell) { if (offer.sell && !player.isArtificial) {
Repository.sendNews(player.username + " just offered " + offer.amount + " " + getItemName(offer.itemID) + " on the GE.") 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() offer.writeNew()
@ -299,6 +308,7 @@ class GrandExchange : StartupListener, Commands {
if(canUpdatePriceIndex(seller, buyer)) if(canUpdatePriceIndex(seller, buyer))
PriceIndex.addTrade(offer.itemID, amount, (totalCoinXC / amount)) PriceIndex.addTrade(offer.itemID, amount, (totalCoinXC / amount))
/*
if (seller.amountLeft > 0) { if (seller.amountLeft > 0) {
Discord.postOfferUpdate(true, seller.itemID, seller.offeredValue, seller.amountLeft) Discord.postOfferUpdate(true, seller.itemID, seller.offeredValue, seller.amountLeft)
} }
@ -306,6 +316,7 @@ class GrandExchange : StartupListener, Commands {
if (buyer.amountLeft > 0) { if (buyer.amountLeft > 0) {
Discord.postOfferUpdate(false, buyer.itemID, buyer.offeredValue, buyer.amountLeft) Discord.postOfferUpdate(false, buyer.itemID, buyer.offeredValue, buyer.amountLeft)
} }
*/
seller.update() seller.update()
val sellerPlayer = Repository.uid_map[seller.playerUID] val sellerPlayer = Repository.uid_map[seller.playerUID]

View file

@ -1,5 +1,6 @@
package rs09.game.ge package rs09.game.ge
import api.getAttribute
import core.cache.def.impl.ItemDefinition import core.cache.def.impl.ItemDefinition
import core.game.ge.OfferState import core.game.ge.OfferState
import core.game.node.entity.player.Player import core.game.node.entity.player.Player
@ -144,7 +145,11 @@ class GrandExchangeOffer() {
uid = nowuid.getLong(1) uid = nowuid.getLong(1)
visualize(player) visualize(player)
stmt.close() 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)
} }
} }
} }