Implemented ::ge mute command for players to mute the global news announcement for GE trades
This commit is contained in:
@@ -502,7 +502,10 @@ class ScriptAPI(private val bot: Player) {
|
|||||||
}
|
}
|
||||||
val canSell = GrandExchange.addBotOffer(actualId, itemAmt)
|
val canSell = GrandExchange.addBotOffer(actualId, itemAmt)
|
||||||
if (canSell && saleIsBigNews(actualId, itemAmt)) {
|
if (canSell && saleIsBigNews(actualId, itemAmt)) {
|
||||||
Repository.sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE.")
|
Repository.sendGrandExchangeNews(
|
||||||
|
SERVER_GE_NAME + " just offered " + itemAmt + " " +
|
||||||
|
ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
bot.bank.remove(Item(id, itemAmt))
|
bot.bank.remove(Item(id, itemAmt))
|
||||||
bot.bank.refresh()
|
bot.bank.refresh()
|
||||||
@@ -532,7 +535,10 @@ class ScriptAPI(private val bot: Player) {
|
|||||||
}
|
}
|
||||||
val canSell = GrandExchange.addBotOffer(actualId, itemAmt)
|
val canSell = GrandExchange.addBotOffer(actualId, itemAmt)
|
||||||
if (canSell && saleIsBigNews(actualId, itemAmt)) {
|
if (canSell && saleIsBigNews(actualId, itemAmt)) {
|
||||||
Repository.sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE.")
|
Repository.sendGrandExchangeNews(
|
||||||
|
SERVER_GE_NAME + " just offered " + itemAmt + " " +
|
||||||
|
ItemDefinition.forId(actualId).name.toLowerCase() + " on the GE."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
bot.bank.remove(item)
|
bot.bank.remove(item)
|
||||||
bot.bank.refresh()
|
bot.bank.refresh()
|
||||||
@@ -568,7 +574,10 @@ class ScriptAPI(private val bot: Player) {
|
|||||||
1517 -> continue
|
1517 -> continue
|
||||||
1519 -> continue
|
1519 -> continue
|
||||||
1521 -> continue
|
1521 -> continue
|
||||||
else -> sendNews(SERVER_GE_NAME + " just offered " + itemAmt + " " + ItemDefinition.forId(actualId).name.lowercase() + " on the GE.")
|
else -> Repository.sendGrandExchangeNews(
|
||||||
|
SERVER_GE_NAME + " just offered " + itemAmt + " " +
|
||||||
|
ItemDefinition.forId(actualId).name.lowercase() + " on the GE."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bot.bank.remove(item)
|
bot.bank.remove(item)
|
||||||
|
|||||||
@@ -221,7 +221,9 @@ class GrandExchange : StartupListener, Commands {
|
|||||||
//GrandExchangeRecords.getInstance(player).update(offer)
|
//GrandExchangeRecords.getInstance(player).update(offer)
|
||||||
|
|
||||||
if (offer.sell && !player.isArtificial) {
|
if (offer.sell && !player.isArtificial) {
|
||||||
sendNews(player.username + " just offered " + offer.amount + " " + getItemName(offer.itemID) + " on the GE.")
|
Repository.sendGrandExchangeNews(
|
||||||
|
player.username + " just offered " + offer.amount + " " + getItemName(offer.itemID) + " on the GE."
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ServerConstants.I_AM_A_CHEATER) {
|
if (ServerConstants.I_AM_A_CHEATER) {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import core.game.system.command.CommandMapping
|
|||||||
import core.game.system.command.Privilege
|
import core.game.system.command.Privilege
|
||||||
import core.game.system.communication.CommunicationInfo
|
import core.game.system.communication.CommunicationInfo
|
||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
|
import core.game.world.repository.GE_NEWS_MUTE_ATTRIBUTE
|
||||||
import core.game.world.map.build.DynamicRegion
|
import core.game.world.map.build.DynamicRegion
|
||||||
import core.game.world.repository.Repository
|
import core.game.world.repository.Repository
|
||||||
import core.game.node.entity.combat.equipment.WeaponInterface
|
import core.game.node.entity.combat.equipment.WeaponInterface
|
||||||
@@ -252,21 +253,38 @@ class MiscCommandSet : CommandSet(Privilege.ADMIN){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows the player a list of currently active GE sell offers
|
* Shows the player a list of currently active GE sell offers or toggles muting sell offer News announcements.
|
||||||
*/
|
*/
|
||||||
define("ge", Privilege.STANDARD, "::ge <lt>MODE<gt> (Modes: buying, selling, search, bots, botsearch)", "Various commands for viewing GE offers.") { player, args ->
|
define(
|
||||||
if(args.size < 2){
|
"ge",
|
||||||
reject(player, "Usage: ::ge mode", "Available modes: buying, selling, search, bots, botsearch")
|
Privilege.STANDARD,
|
||||||
|
"::ge <lt>MODE<gt> (Modes: buying, selling, search, bots, botsearch, mute)",
|
||||||
|
"Various commands for viewing GE offers."
|
||||||
|
) { player, args ->
|
||||||
|
if (args.size < 2) {
|
||||||
|
reject(player, "Usage: ::ge mode", "Available modes: buying, selling, search, bots, botsearch, mute")
|
||||||
}
|
}
|
||||||
|
|
||||||
val mode = args[1]
|
val mode = args[1]
|
||||||
when(mode){
|
when (mode) {
|
||||||
"buying" -> showGeBuy(player)
|
"buying" -> showGeBuy(player)
|
||||||
"selling" -> showGeSell(player)
|
"selling" -> showGeSell(player)
|
||||||
"search" -> showGeInputDialogue(player, args, ::showOffers)
|
"search" -> showGeInputDialogue(player, args, ::showOffers)
|
||||||
"bots" -> showGeBots(player)
|
"bots" -> showGeBots(player)
|
||||||
"botsearch" -> showGeInputDialogue(player, args, ::showGeBotsearch)
|
"botsearch" -> showGeInputDialogue(player, args, ::showGeBotsearch)
|
||||||
else -> reject(player, "Invalid mode used. Available modes are: buying, selling, search")
|
"mute" -> {
|
||||||
|
val currentlyMuted = getAttribute(player, GE_NEWS_MUTE_ATTRIBUTE, false)
|
||||||
|
if (currentlyMuted) {
|
||||||
|
removeAttribute(player, GE_NEWS_MUTE_ATTRIBUTE)
|
||||||
|
} else {
|
||||||
|
setAttribute(player, GE_NEWS_MUTE_ATTRIBUTE, true)
|
||||||
|
}
|
||||||
|
sendMessage(player, "GE sell offer news is now ${if (currentlyMuted) "visible" else "hidden"}.")
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> reject(
|
||||||
|
player,
|
||||||
|
"Invalid mode used. Available modes are: buying, selling, search, bots, botsearch, mute"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
package core.game.world.repository
|
package core.game.world.repository
|
||||||
|
|
||||||
import core.game.node.entity.npc.NPC
|
|
||||||
import content.region.wilderness.handlers.revenants.RevenantNPC
|
import content.region.wilderness.handlers.revenants.RevenantNPC
|
||||||
|
import core.ServerConstants
|
||||||
|
import core.api.sendMessage
|
||||||
|
import core.game.node.entity.npc.NPC
|
||||||
import core.game.node.entity.player.Player
|
import core.game.node.entity.player.Player
|
||||||
import core.game.world.map.Location
|
import core.game.world.map.Location
|
||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
import core.ServerConstants
|
|
||||||
import core.api.sendMessage
|
|
||||||
import core.game.world.update.UpdateSequence
|
import core.game.world.update.UpdateSequence
|
||||||
import java.util.*
|
|
||||||
import java.util.concurrent.CopyOnWriteArrayList
|
import java.util.concurrent.CopyOnWriteArrayList
|
||||||
|
|
||||||
|
const val GE_NEWS_MUTE_ATTRIBUTE = "/save:ge:news-mute"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The repository holding all node lists, etc in the game world.
|
* The repository holding all node lists, etc in the game world.
|
||||||
* @author Emperor
|
* @author Emperor
|
||||||
@@ -64,11 +65,22 @@ object Repository {
|
|||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun sendNews(string: String, icon: Int = 12, color: String = "CC6600") {
|
fun sendNews(string: String, icon: Int = 12, color: String = "CC6600") {
|
||||||
|
sendNews(string, icon, color, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun sendGrandExchangeNews(string: String, icon: Int = 12, color: String = "CC6600") {
|
||||||
|
sendNews(string, icon, color, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun sendNews(string: String, icon: Int, color: String, isGeNews: Boolean) {
|
||||||
if (!ServerConstants.ENABLE_GLOBAL_CHAT) return
|
if (!ServerConstants.ENABLE_GLOBAL_CHAT) return
|
||||||
val players: Array<Any> = playerNames.values.toTypedArray()
|
val players: Array<Any> = playerNames.values.toTypedArray()
|
||||||
val size = players.size
|
val size = players.size
|
||||||
for (i in 0 until size) {
|
for (i in 0 until size) {
|
||||||
val player = players[i] as Player ?: continue
|
val player = players[i] as? Player ?: continue
|
||||||
|
if (isGeNews && player.getAttribute(GE_NEWS_MUTE_ATTRIBUTE, false)) continue
|
||||||
sendMessage(player, "<img=$icon><col=$color>News: $string")
|
sendMessage(player, "<img=$icon><col=$color>News: $string")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user