Skip to content

Commit

Permalink
Hook TrMenu
Browse files Browse the repository at this point in the history
  • Loading branch information
Arasple committed Feb 12, 2021
1 parent 2ca292b commit 9368df1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group 'me.arasple.mc.trhologram'
version '2.0-BETA2'
version '2.0-BETA3'

task buildJar(dependsOn: [clean, shadowJar])

Expand Down
Binary file added libs/TrMenu-3.0-Beta6-all.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import me.arasple.mc.trhologram.module.action.Reaction
import me.arasple.mc.trhologram.module.condition.Condition
import me.arasple.mc.trhologram.module.display.Hologram
import me.arasple.mc.trhologram.module.display.texture.Texture
import me.arasple.mc.trhologram.module.display.texture.TrMenuTexture
import me.arasple.mc.trhologram.module.hook.HookPlugin
import me.arasple.mc.trhologram.util.Parser
import org.bukkit.Location
import org.bukkit.command.CommandSender
Expand Down Expand Up @@ -105,11 +107,12 @@ object HologramLoader {
val offset = options[Property.OFFSET]?.toDoubleOrNull() ?: lineSpacing
val isItem = itemDisplay != null
val fix = if (isItem) 0.5 else 0.0
val texture = if (!HookPlugin.TRMENU) Texture.createTexture(itemDisplay!!) else TrMenuTexture(itemDisplay!!)

position = position.clone(y = -(fix + offset))

val hologram = when {
isItem -> ItemHologram(Texture.createTexture(itemDisplay!!), position, update)
isItem -> ItemHologram(texture, position, update)
line.isBlank() -> null
else -> TextHologram(line, position, update)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package me.arasple.mc.trhologram.module.display.texture

import me.arasple.mc.trhologram.api.base.ItemTexture
import me.arasple.mc.trmenu.module.display.MenuSession
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack

/**
* @author Arasple
* @date 2021/2/12 21:11
*/
class TrMenuTexture(texture: String) : ItemTexture {

private val texture = me.arasple.mc.trmenu.module.display.texture.Texture.createTexture(texture)

override fun generate(player: Player): ItemStack {
return texture.generate(MenuSession.getSession(player))
}


}
17 changes: 17 additions & 0 deletions src/main/kotlin/me/arasple/mc/trhologram/module/hook/HookPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package me.arasple.mc.trhologram.module.hook

import org.bukkit.Bukkit

/**
* @author Arasple
* @date 2021/2/12 21:12
*/
object HookPlugin {

val TRMENU by lazy {

Bukkit.getPluginManager().getPlugin("TrMenu")?.isEnabled ?: false

}

}

0 comments on commit 9368df1

Please sign in to comment.