本帖最后由 贺兰兰 于 2021-4-30 21:53 编辑
(别问我为啥不发到隔壁版,因为这个代码很久以前写的,而且实现真的太脏了,完全就是写出来娱乐的,所以大家也图个乐就好,仅供参考)
↓之所以要发是因为刚才整理仓库突然看到这个觉得挺有意思就分享出来了
代码源: https://github.com/shaokeyibb/Ci ... features/BlinkMe.kt
复制代码
运行原理: 每隔一定时间给予玩家失明和夜视的效果,这样玩家看起来会先啥都看不见然后逐渐恢复视野,就像眨眼一样。
虽然实现比较脏,但是玩起来还是挺有意思的,甚至挺真实2333。
(源代码上还有一个当玩家眨眼时会在头顶显示的眨眼 Tag 和一个类似 SCPSL 的剩余眨眼时间 Actionbar,可以说很真实了
来自群组: Server CT
(别问我为啥不发到隔壁版,因为这个代码很久以前写的,而且实现真的太脏了,完全就是写出来娱乐的,所以大家也图个乐就好,仅供参考)
↓之所以要发是因为刚才整理仓库突然看到这个觉得挺有意思就分享出来了
代码源: https://github.com/shaokeyibb/Ci ... features/BlinkMe.kt
- package kim.minecraft.citycore.features
- import io.izzel.taboolib.internal.xseries.messages.ActionBar
- import kim.minecraft.citycore.CityCore
- import kim.minecraft.citycore.player.Player
- import kim.minecraft.citycore.player.PlayerManager.toCCPlayer
- import kim.minecraft.citycore.utils.HologramTags
- import kim.minecraft.citycore.utils.storage.SettingsStorage
- import org.bukkit.event.EventHandler
- import org.bukkit.event.Listener
- import org.bukkit.event.player.PlayerJoinEvent
- import org.bukkit.event.player.PlayerQuitEvent
- import org.bukkit.potion.PotionEffect
- import org.bukkit.potion.PotionEffectType
- import org.bukkit.scheduler.BukkitRunnable
- import kotlin.random.Random
- object BlinkMe : Listener {
- private val list = mutableMapOf<Player, Action>()
- @EventHandler
- fun onRegister(e: PlayerJoinEvent) {
- if (e.player.toCCPlayer() == null) return
- list[e.player.toCCPlayer()!!] = Action(e.player.toCCPlayer()!!)
- }
- @EventHandler
- fun onUnregister(e: PlayerQuitEvent) {
- if (e.player.toCCPlayer() == null) return
- list.remove(e.player.toCCPlayer()!!)!!.also { it.unregister() }
- }
- class Action(val player: Player) {
- val blindTime = Random.nextLong(SettingsStorage.settings.getLong("HumanRaceEyesBlindMinDelay", 40), SettingsStorage.settings.getLong("HumanRaceEyesBlindMaxDelay", 120))
- val refreshTime = SettingsStorage.settings.getLong("HumanRaceEyesBlindRefreshTimeTicks", 5)
- fun unregister() {
- action.cancel()
- }
- private val action = object : BukkitRunnable() {
- override fun run() {
- val time = Random.nextInt(SettingsStorage.settings.getInt("HumanRaceEyesBlindMinDuration", 24), SettingsStorage.settings.getInt("HumanRaceEyesBlindMaxDuration", 28))
- player.getBukkitPlayer().addPotionEffect(PotionEffect(PotionEffectType.BLINDNESS, time, 255, false, false, false))
- player.getBukkitPlayer().addPotionEffect(PotionEffect(PotionEffectType.NIGHT_VISION, time, 255, false, false, false))
- HologramTags.addTags(player, "!眨眼!")
- object : BukkitRunnable() {
- override fun run() {
- HologramTags.removeTag(player, "!眨眼!")
- }
- }.runTaskLater(CityCore.plugin, time.toLong())
- object : BukkitRunnable() {
- var now = blindTime.toInt()
- override fun run() {
- try {
- var i = 0
- val string = StringBuilder()
- while (i <= now) {
- if ((i % refreshTime.toInt()) == 0) string.append("█")
- i++
- }
- ActionBar.sendActionBar(player.getBukkitPlayer(), string.toString())
- now--
- if (now == 0) cancel()
- } catch (ignored: NullPointerException) {
- cancel()
- }
- }
- }.runTaskTimerAsynchronously(CityCore.plugin, 0, 1)
- }
- }
- init {
- action.runTaskTimer(CityCore.plugin, 20, blindTime)
- }
- }
- }
运行原理: 每隔一定时间给予玩家失明和夜视的效果,这样玩家看起来会先啥都看不见然后逐渐恢复视野,就像眨眼一样。
虽然实现比较脏,但是玩起来还是挺有意思的,甚至挺真实2333。
(源代码上还有一个当玩家眨眼时会在头顶显示的眨眼 Tag 和一个类似 SCPSL 的剩余眨眼时间 Actionbar,可以说很真实了
来自群组: Server CT
本帖最后由 MC_小六 于 2021-4-30 21:54 编辑
虽然知道这只是瞎玩,但是感觉如果用了虽然真实 但是游戏体验会很差吧(
虽然知道这只是瞎玩,但是感觉如果用了虽然真实 但是游戏体验会很差吧(
萌新表示看不懂。
确实,但可能降低体验感?
我感觉非但没有让游戏更真实
反而使其更难了……
祝贺兰高考顺利!
反而使其更难了……
祝贺兰高考顺利!
有一说一毫无用处啊哈哈
这…… 有意思 但人类正常眨眼是不会有突然看不见然后恢复视野的吧
LeoPro 发表于 2021-5-1 00:06
这…… 有意思 但人类正常眨眼是不会有突然看不见然后恢复视野的吧
可以想一下在太阳光下睁眼,眼睛的那个适应过程233
眨眼?这不再写个173合起来用
