Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
javaVersion=25
mcVersion=1.21.11
group=dev.slne.surf
version=1.21.11-2.67.0
version=1.21.11-2.67.1
relocationPrefix=dev.slne.surf.surfapi.libs
snapshot=false
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

package dev.slne.surf.surfapi.bukkit.api.inventory.framework

import dev.slne.surf.surfapi.bukkit.api.builder.buildItem
import dev.slne.surf.surfapi.bukkit.api.builder.displayName
import dev.slne.surf.surfapi.bukkit.api.inventory.framework.view.InventoryFrameworkDSL
import dev.slne.surf.surfapi.core.api.messages.builder.SurfComponentBuilder
import me.devnatan.inventoryframework.View
import me.devnatan.inventoryframework.ViewConfigBuilder
import me.devnatan.inventoryframework.context.OpenContext
import net.kyori.adventure.text.Component
import org.bukkit.Material
import org.bukkit.entity.Player

/**
Expand Down Expand Up @@ -142,4 +146,9 @@ inline fun ViewConfigBuilder.titleBuilder(title: @InventoryFrameworkDSL SurfComp
* @param modifier DSL block applied to the [ViewConfigBuilder]
*/
inline fun OpenContext.modifyConfig(modifier: @InventoryFrameworkDSL ViewConfigBuilder.() -> Unit) =
this.modifyConfig().apply(modifier)
this.modifyConfig().apply(modifier)

val View.outlineItem
get() = buildItem(Material.GRAY_STAINED_GLASS_PANE) {
displayName(Component.empty())
}
Comment thread
TheBjoRedCraft marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

package dev.slne.surf.surfapi.bukkit.api.util

import com.github.retrooper.packetevents.PacketEvents
import com.github.retrooper.packetevents.wrapper.PacketWrapper
import com.github.shynixn.mccoroutine.folia.SuspendingPlugin
import com.github.shynixn.mccoroutine.folia.entityDispatcher
import com.github.shynixn.mccoroutine.folia.regionDispatcher
Expand Down Expand Up @@ -281,3 +283,18 @@ suspend fun World.getBlockAtAsync(pos: BlockPosition): Block {
)
}
}

fun PacketWrapper<*>.sendPacket(uuid: UUID) {
val player = Bukkit.getPlayer(uuid) ?: return
val packetPlayer = PacketEvents.getAPI().playerManager.getUser(player) ?: return

packetPlayer.sendPacket(this)
Comment thread
TheBjoRedCraft marked this conversation as resolved.
Outdated
}

fun PacketWrapper<*>.sendPacket(player: Player) =
PacketEvents.getAPI().playerManager.getUser(player)?.sendPacket(this)
Comment thread
TheBjoRedCraft marked this conversation as resolved.
Outdated

fun Location.readableString(showRotation: Boolean) =
"${world?.name ?: "null"}: (${x.toInt()}, ${y.toInt()}, ${z.toInt()})" + if (showRotation) " (yaw: ${yaw.toInt()}, pitch: ${pitch.toInt()})" else ""
Comment thread
TheBjoRedCraft marked this conversation as resolved.
Outdated

typealias BukkitSound = Sound
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ inline fun Audience.sendText(block: SurfComponentBuilder.() -> Unit) {
sendMessage(SurfComponentBuilder(block))
}

inline fun Audience.sendActionBar(block: SurfComponentBuilder.() -> Unit) {
sendActionBar(SurfComponentBuilder(block))
}

inline fun Audience.openBook(block: @BookDsl Book.Builder.() -> Unit) {
openBook(Book(block))
}
Expand Down Expand Up @@ -45,8 +49,11 @@ inline fun Audience.uuid() = uuidOrNull() ?: error("Audience does not have a UUI
inline fun Audience.nameOrNull() = getPointer(Identity.NAME)
inline fun Audience.name() = nameOrNull() ?: error("Audience does not have a name pointer")
inline fun Audience.displayNameOrNull() = getPointer(Identity.DISPLAY_NAME)
inline fun Audience.displayName() = displayNameOrNull() ?: error("Audience does not have a display name pointer")
inline fun Audience.displayName() =
displayNameOrNull() ?: error("Audience does not have a display name pointer")

inline fun Audience.testPermission(permission: String) =
getPointer(PermissionChecker.POINTER)?.value(permission) ?: TriState.NOT_SET

inline fun Audience.hasPermission(permission: String) = getPointer(PermissionChecker.POINTER)?.test(permission) ?: false
inline fun Audience.hasPermission(permission: String) =
getPointer(PermissionChecker.POINTER)?.test(permission) ?: false
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,6 @@ inline fun sound(block: @SoundDsl Sound.Builder.() -> Unit): Sound {
* @param block The configuration block for building the sound.
* @return A configured [Sound] instance.
*/
inline fun Sound(block: @SoundDsl Sound.Builder.() -> Unit) = sound(block)
inline fun Sound(block: @SoundDsl Sound.Builder.() -> Unit) = sound(block)

Comment thread
TheBjoRedCraft marked this conversation as resolved.
typealias AdventureSound = Sound
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package dev.slne.surf.surfapi.core.api.messages.builder

import dev.slne.surf.surfapi.core.api.messages.*
import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.NOTE
import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.PREFIX
import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.SPACER
import dev.slne.surf.surfapi.core.api.messages.Colors.Companion.VARIABLE_VALUE
Comment thread
TheBjoRedCraft marked this conversation as resolved.
import dev.slne.surf.surfapi.core.api.messages.CommonComponents
import dev.slne.surf.surfapi.core.api.messages.CommonComponents.DISCONNECT_HEADER
import dev.slne.surf.surfapi.core.api.messages.CommonComponents.DISCORD_LINK
import dev.slne.surf.surfapi.core.api.messages.CommonComponents.TIME_SEPARATOR
import dev.slne.surf.surfapi.core.api.messages.NoLowercase
import dev.slne.surf.surfapi.core.api.messages.joinToComponent
import dev.slne.surf.surfapi.core.api.messages.joinToComponentNewLine
import net.kyori.adventure.key.Key
import net.kyori.adventure.text.*
import net.kyori.adventure.text.event.ClickEvent
Expand Down Expand Up @@ -83,6 +80,11 @@ interface SurfComponentBuilder : TextComponent.Builder, ComponentBuilderColors {
fun note(any: Any, vararg decoration: TextDecoration) = text(any.toString(), NOTE, *decoration)

fun ellipsis(color: TextColor? = SPACER) = append(CommonComponents.ELLIPSIS.color(color))
fun translatable(
key: String,
color: TextColor? = Colors.WHITE,
vararg decoration: TextDecoration
) = append(Component.translatable(key, color, *decoration))

fun appendDiscordLink() = append(DISCORD_LINK)
fun appendDisconnectHeader() = append(DISCONNECT_HEADER)
Expand Down
Loading