Fixed some ContentAPI issues introduced by !410
This commit is contained in:
@@ -4,7 +4,6 @@ import core.cache.def.impl.ItemDefinition
|
|||||||
import core.cache.def.impl.SceneryDefinition
|
import core.cache.def.impl.SceneryDefinition
|
||||||
import core.game.component.Component
|
import core.game.component.Component
|
||||||
import core.game.container.impl.EquipmentContainer
|
import core.game.container.impl.EquipmentContainer
|
||||||
import core.game.container.impl.InventoryListener
|
|
||||||
import core.game.content.dialogue.FacialExpression
|
import core.game.content.dialogue.FacialExpression
|
||||||
import core.game.content.global.action.SpecialLadders
|
import core.game.content.global.action.SpecialLadders
|
||||||
import core.game.node.Node
|
import core.game.node.Node
|
||||||
@@ -38,10 +37,10 @@ import core.game.world.map.zone.ZoneBuilder
|
|||||||
import core.game.world.update.flag.chunk.AnimateObjectUpdateFlag
|
import core.game.world.update.flag.chunk.AnimateObjectUpdateFlag
|
||||||
import core.game.world.update.flag.context.Animation
|
import core.game.world.update.flag.context.Animation
|
||||||
import core.game.world.update.flag.context.Graphics
|
import core.game.world.update.flag.context.Graphics
|
||||||
import core.plugin.Plugin
|
|
||||||
import rs09.game.content.dialogue.DialogueFile
|
import rs09.game.content.dialogue.DialogueFile
|
||||||
import rs09.game.content.dialogue.SkillDialogueHandler
|
import rs09.game.content.dialogue.SkillDialogueHandler
|
||||||
import rs09.game.content.global.GlobalKillCounter;
|
import rs09.game.content.global.GlobalKillCounter;
|
||||||
|
import rs09.game.interaction.InteractionListeners
|
||||||
import rs09.game.system.SystemLogger
|
import rs09.game.system.SystemLogger
|
||||||
import rs09.game.system.config.ItemConfigParser;
|
import rs09.game.system.config.ItemConfigParser;
|
||||||
import rs09.game.world.GameWorld
|
import rs09.game.world.GameWorld
|
||||||
@@ -135,6 +134,18 @@ fun isEquipped(player: Player, id: Int): Boolean {
|
|||||||
return amountInEquipment(player, id) > 0
|
return amountInEquipment(player, id) > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a player has an item equipped which corresponds to the given God
|
||||||
|
* @param player the player to check
|
||||||
|
* @param god the God whose equipment we are checking for
|
||||||
|
* @return true if the player has an item corresponding to the given god, false otherwise
|
||||||
|
*/
|
||||||
|
fun hasGodItem(player: Player, god: God): Boolean
|
||||||
|
{
|
||||||
|
god.validItems.forEach { if(amountInEquipment(player, it) > 0) return true }
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove an item from a player's inventory
|
* Remove an item from a player's inventory
|
||||||
* @param player the player whose inventory to remove the item from
|
* @param player the player whose inventory to remove the item from
|
||||||
@@ -157,18 +168,6 @@ fun <T> removeItem(player: Player, item: T, container: Container = Container.INV
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an item to a player's inventory
|
|
||||||
* @param player the player whose inventory to add an item to
|
|
||||||
* @param id the ID of the item to add
|
|
||||||
* @param amount the amount of the item to add, defaults to 1
|
|
||||||
* @return true if the item exists in the given amount in the player's inventory
|
|
||||||
*/
|
|
||||||
|
|
||||||
fun addItem(player: Player, id: Int, amount: Int = 1): Boolean{
|
|
||||||
return addItem(player, id, amount, Container.INVENTORY)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add an item to the given player's given container
|
* Add an item to the given player's given container
|
||||||
* @param player the player whose container to modify
|
* @param player the player whose container to modify
|
||||||
@@ -261,18 +260,6 @@ fun inEquipment(player: Player, item: Int, amount: Int = 1): Boolean {
|
|||||||
return player.equipment.contains(item, amount)
|
return player.equipment.contains(item, amount)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a player has an item equipped which corresponds to the given God
|
|
||||||
* @param player the player to check
|
|
||||||
* @param god the God whose equipment we are checking for
|
|
||||||
* @return true if the player has an item corresponding to the given god, false otherwise
|
|
||||||
*/
|
|
||||||
fun hasGodItem(player: Player, god: God): Boolean
|
|
||||||
{
|
|
||||||
god.validItems.forEach { if(amountInEquipment(player, it) > 0) return true }
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get number of free slots in a player's inventory
|
* Get number of free slots in a player's inventory
|
||||||
* @param player the player to check
|
* @param player the player to check
|
||||||
@@ -1382,36 +1369,32 @@ fun announceIfRare(player: Player, item: Item) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a Mutable List of player skills that are at 99, returns false if player has no 99s
|
* Generates a list of skill names which the player has mastered
|
||||||
* @param player the player
|
* @param player the player
|
||||||
|
* @return a List<String> of skill names
|
||||||
*/
|
*/
|
||||||
|
|
||||||
fun getMasteredSkills(player: Player): MutableList<String> {
|
fun getMasteredSkillNames(player: Player): List<String> {
|
||||||
val SKILL_LIST = Skills.SKILL_NAME
|
val masteredSkills = ArrayList<String>()
|
||||||
val hasMastered = player.getSkills().masteredSkills > 0
|
|
||||||
val MASTERED_SKILLS = mutableListOf<String>()
|
|
||||||
|
|
||||||
if(hasMastered){
|
for ((skillId, skillName) in Skills.SKILL_NAME.withIndex()) {
|
||||||
SKILL_LIST.forEach {
|
if(hasLevelStat(player, skillId, 99)){
|
||||||
when(player.getSkills().getLevel(Skills.getSkillByName(it))){
|
masteredSkills.add(skillName)
|
||||||
99 -> MASTERED_SKILLS.add(it)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
return masteredSkills
|
||||||
return MASTERED_SKILLS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps a container.
|
* Dumps the given player's given container into that player's bank.
|
||||||
* @param player the player
|
* @param player the player
|
||||||
* @param inventory the player's inventory.
|
* @param container the player's container to dump.
|
||||||
* @param boolean true to send message stating why it can't bank, false for no message
|
|
||||||
* @author ceik
|
* @author ceik
|
||||||
* @author James Triantafylos
|
* @author James Triantafylos
|
||||||
*/
|
*/
|
||||||
fun dumpContainer(player: Player, inventory: core.game.container.Container) {
|
fun dumpContainer(player: Player, container: core.game.container.Container) {
|
||||||
val bank = player.bank
|
val bank = player.bank
|
||||||
for (item: Item in inventory.toArray().filterNotNull()) {
|
container.toArray().filterNotNull().forEach { item ->
|
||||||
if (!bank.hasSpaceFor(item)) {
|
if (!bank.hasSpaceFor(item)) {
|
||||||
player.packetDispatch.sendMessage("You have no more space in your bank.")
|
player.packetDispatch.sendMessage("You have no more space in your bank.")
|
||||||
return
|
return
|
||||||
@@ -1420,16 +1403,16 @@ fun dumpContainer(player: Player, inventory: core.game.container.Container) {
|
|||||||
player.packetDispatch.sendMessage("A magical force prevents you from banking your " + item.name + ".")
|
player.packetDispatch.sendMessage("A magical force prevents you from banking your " + item.name + ".")
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
if (inventory is EquipmentContainer) {
|
if (container is EquipmentContainer) {
|
||||||
val plugin = item.definition.handlers["equipment"]
|
if(!InteractionListeners.run(item.id,player,item,false)) {
|
||||||
if (plugin != null && plugin is Plugin<*>) {
|
player.packetDispatch.sendMessage("A magical force prevents you from removing that item.")
|
||||||
plugin.fireEvent("unequip", player, item)
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inventory.remove(item)
|
container.remove(item)
|
||||||
bank.add(if (item.definition.isUnnoted) item else Item(item.noteChange, item.amount))
|
bank.add(if (item.definition.isUnnoted) item else Item(item.noteChange, item.amount))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inventory.update()
|
container.update()
|
||||||
bank.update()
|
bank.update()
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user