ユーザーごとに送信する時間packetを変えるskript

import:
ch.njol.skript.Skript
org.bukkit.plugin.Plugin

com.comphenix.protocol.events.ListenerPriority
com.comphenix.protocol.events.PacketAdapter
com.comphenix.protocol.events.PacketEvent
com.comphenix.protocol.ProtocolLibrary
com.comphenix.protocol.PacketType

java.lang.Override

preimport:
jp.nlaocs.TimePacket

public class TimePacket extends PacketAdapter:

public TimePacket():
super[Plugin, ListenerPriority, PacketType[]](Skript.getInstance(), ListenerPriority.NORMAL, [PacketType.Play.Server.UPDATE_TIME as PacketType])

@Override
public void onPacketSending(PacketEvent event):
if {time::%{_event}.getPlayer().getUniqueId()%} is set:
set {_timeOfDay} to {time::%{_event}.getPlayer().getUniqueId()%}
{_event}.getPacket().getLongs().write(1, {_TimeOfDay})

on load:
set {-timepacketlistener} to new TimePacket()
ProtocolLibrary.getProtocolManager().addPacketListener({-timePacketListener})

on unload:
ProtocolLibrary.getProtocolManager().removePacketListener({-timePacketListener})
delete {-timepacketlistener}

command /mytime <integer>:
trigger:
set {_time} to negate(mod(arg-1, 24000))
set {time::%player's uuid%} to {_time}
send "&a時間を%arg%に設定しました" to player

command /mytimeclear:
trigger:
clear {time::%player's uuid%}
send "&a時間をクリアしました" to player

function negate(value: number) :: number:
return "-%{_value}%" parsed as number
import:
ch.njol.skript.Skript
org.bukkit.plugin.Plugin

com.comphenix.protocol.events.ListenerPriority
com.comphenix.protocol.events.PacketAdapter
com.comphenix.protocol.events.PacketEvent
com.comphenix.protocol.ProtocolLibrary
com.comphenix.protocol.PacketType

java.lang.Override

preimport:
jp.nlaocs.TimePacket

public class TimePacket extends PacketAdapter:

public TimePacket():
super[Plugin, ListenerPriority, PacketType[]](Skript.getInstance(), ListenerPriority.NORMAL, [PacketType.Play.Server.UPDATE_TIME as PacketType])

@Override
public void onPacketSending(PacketEvent event):
if {time::%{_event}.getPlayer().getUniqueId()%} is set:
set {_timeOfDay} to {time::%{_event}.getPlayer().getUniqueId()%}
{_event}.getPacket().getLongs().write(1, {_TimeOfDay})

on load:
set {-timepacketlistener} to new TimePacket()
ProtocolLibrary.getProtocolManager().addPacketListener({-timePacketListener})

on unload:
ProtocolLibrary.getProtocolManager().removePacketListener({-timePacketListener})
delete {-timepacketlistener}

command /mytime <integer>:
trigger:
set {_time} to negate(mod(arg-1, 24000))
set {time::%player's uuid%} to {_time}
send "&a時間を%arg%に設定しました" to player

command /mytimeclear:
trigger:
clear {time::%player's uuid%}
send "&a時間をクリアしました" to player

function negate(value: number) :: number:
return "-%{_value}%" parsed as number
前提: skript-reflect, hippo 朝にゾンビが湧いたり夜にゾンビが燃えたりする世界が作れます
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server