Skip to content

Commit

Permalink
#392 Fixed placeholder api resolving in gui. --snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Shynixn committed Jul 13, 2020
1 parent f99c545 commit bc13d77
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

package com.github.shynixn.petblocks.core.logic.business.service

import com.github.shynixn.petblocks.api.PetBlocksApi
import com.github.shynixn.petblocks.api.business.enumeration.*
import com.github.shynixn.petblocks.api.business.localization.Messages
import com.github.shynixn.petblocks.api.business.service.*
Expand Down Expand Up @@ -55,11 +56,13 @@ class GUIServiceImpl @Inject constructor(
private val headDatabaseService: DependencyHeadDatabaseService,
private val messageService: MessageService,
private val proxyService: ProxyService,
private val guiPetStorageService: GUIPetStorageService
private val guiPetStorageService: GUIPetStorageService,
private val dependencyService: DependencyService
) : GUIService {

private val clickProtection = ArrayList<Any>()
private val pageCache = HashMap<Any, GuiPlayerCache>()
private var placeHolderService: DependencyPlaceholderApiService? = null

private var collectedMinecraftHeadsMessage = lazy {
chatMessage {
Expand Down Expand Up @@ -206,6 +209,10 @@ class GUIServiceImpl @Inject constructor(
override fun <P> open(player: P, pageName: String?) {
require(player is Any)

if (placeHolderService == null && dependencyService.isInstalled(PluginDependency.PLACEHOLDERAPI)) {
placeHolderService = PetBlocksApi.resolve(DependencyPlaceholderApiService::class.java)
}

proxyService.closeInventory(player)
var page = pageName

Expand Down Expand Up @@ -343,6 +350,11 @@ class GUIServiceImpl @Inject constructor(
val guiIcon = GuiIconEntity()
guiIcon.displayName = petMeta.displayName

if (placeHolderService != null) {
guiIcon.displayName =
placeHolderService!!.applyPlaceHolders(player, petMeta.displayName).translateChatColors()
}

with(guiIcon.skin) {
typeName = petMeta.skin.typeName
dataValue = petMeta.skin.dataValue
Expand Down

0 comments on commit bc13d77

Please sign in to comment.