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.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]

View file

@ -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)
}
}
}