-
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a18576
commit c456080
Showing
36 changed files
with
150 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
version = 0.15-alpha.8 | ||
version = 0.16-alpha.1 | ||
kotlin.daemon.jvmargs=-Xmx2g | ||
org.gradle.jvmargs=-Xmx2g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
nova/src/main/kotlin/xyz/xenondevs/nova/data/resources/upload/ForceResourcePack.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package xyz.xenondevs.nova.data.resources.upload | ||
|
||
import net.kyori.adventure.text.Component | ||
import org.bukkit.event.EventHandler | ||
import org.bukkit.event.Listener | ||
import org.bukkit.event.player.PlayerJoinEvent | ||
import xyz.xenondevs.nova.data.config.MAIN_CONFIG | ||
import xyz.xenondevs.nova.data.config.PermanentStorage | ||
import xyz.xenondevs.nova.data.config.entry | ||
import xyz.xenondevs.nova.data.resources.builder.ResourcePackBuilder | ||
import xyz.xenondevs.nova.initialize.InitFun | ||
import xyz.xenondevs.nova.initialize.InternalInit | ||
import xyz.xenondevs.nova.initialize.InternalInitStage | ||
import xyz.xenondevs.nova.util.data.HashUtils | ||
import xyz.xenondevs.nova.util.registerEvents | ||
import java.util.* | ||
|
||
private val PROMPT_MESSAGE by MAIN_CONFIG.entry<Component>("resource_pack", "prompt", "message") | ||
private val PROMPT_FORCE by MAIN_CONFIG.entry<Boolean>("resource_pack", "prompt", "force") | ||
private val ENABLE_PROMPT_FORCE_BYPASS_PERMISSION by MAIN_CONFIG.entry<Boolean>("resource_pack", "prompt", "enableForceBypassPermission") | ||
private val ENABLE_PROMPT_BYPASS_PERMISSION by MAIN_CONFIG.entry<Boolean>("resource_pack", "prompt", "enablePromptBypassPermission") | ||
|
||
private const val PROMPT_BYPASS_PERMISSION = "nova.misc.resourcePack.bypass.prompt" | ||
private const val FORCE_BYPASS_PERMISSION = "nova.misc.resourcePack.bypass.force" | ||
|
||
@InternalInit(stage = InternalInitStage.POST_WORLD) | ||
internal object ForceResourcePack : Listener { | ||
|
||
private val packId: UUID = PermanentStorage.retrieveOrStore("force_resource_pack_uuid") { UUID.randomUUID() } | ||
|
||
private var hash: ByteArray? = null | ||
private var url: String? = null | ||
|
||
@InitFun | ||
private fun init() { | ||
registerEvents() | ||
} | ||
|
||
@EventHandler | ||
private fun handleJoin(event: PlayerJoinEvent) { | ||
// TODO: replace with net.kyori.adventure.resource api once available | ||
|
||
val url = url | ||
val hash = hash | ||
if (url == null || hash == null) | ||
return | ||
|
||
val player = event.player | ||
if (ENABLE_PROMPT_BYPASS_PERMISSION && player.hasPermission(PROMPT_BYPASS_PERMISSION)) | ||
return | ||
|
||
val force = PROMPT_FORCE && (!ENABLE_PROMPT_FORCE_BYPASS_PERMISSION || !player.hasPermission(FORCE_BYPASS_PERMISSION)) | ||
event.player.setResourcePack(packId, url, hash, PROMPT_MESSAGE, force) | ||
} | ||
|
||
fun setResourcePack(url: String?) { | ||
if (url != null) { | ||
this.url = url | ||
this.hash = HashUtils.getFileHash(ResourcePackBuilder.RESOURCE_PACK_FILE, "SHA1") | ||
} else { | ||
this.url = null | ||
this.hash = null | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.