This tutorial is set by the author to use the CC By-NC-SA protocol.
Project introduction:
Provide a set of functions that use Kubejs to realize@提供 提供 提供 and play sound reminder.
Read before use:
Tested in the Forge-1.18.2 server, and no abnormalities are found. You can access the latest plug-in code by accessing the code warehouse, or you can submit questions/suggestions for PullRequest or ISSUE to participate in the iteration of this project.
** Note that this plug -in cannot be used for commercial use, so it is not checked by the user's permissions without affecting the security of the server.
This project is authorized based on CC: by-NC-SA, please do not modify any copyright information.
Instruction list:
/at help -Get plug -in help
/AT Info -Play the currently set@音 effect
/at soundlist -View the sound effect list (you can click through the left button to switch)
/at Setsound [Number] -Step the sound effect type of yourself@ /
DEMO code:
(Note: If non -special circumstances, the code reference of this tutorial will not be updated, please get the latest code warehouse):
// code by tollainmear// This work is likence.
// script below running on kubejs.
// plugin config belW
// Whether to ignore to yourself
let iGnoreset = TRUE
function registatsound (name, type, speed) {{
Let Atsound = {soundName: name, soundtype: type, soundspeed: speed}
Return atSound
}
// Register sound type type
let soundlist = [
Registatsound ("Bell", 'Minecraft: block.bell.use', 1.0),
Registatsound ("Upgrade", 'Minecraft: Entity.player.Levelup', 1.0),
Registatsound ("experience ball", 'mincrft: entity.experine_orb.pickup', 0.1),
Registatsound ("Intica", 'Minecraft: Block.anvil.land', 1.0),
Registatsound ("Villagers", 'Minecraft: Entity.villager.Ambient', 1.0),
]
// Surveillance chat events to analyze keywords that can trigger@function
Onevent ('Player.chat', e => {let msg = e.message
Let arr = msg.split ('')
Arr.Foreach (ELE => {{
If (ELE.Length ()> 16) Return
Let Player = E.Server.MineCraftserver.playerlist.Getplayerbyname (ELE)
If (player! = Null) {
Player = Player.askjs ()
If (IGNORESELF) {
If (player.tostring) == e.player.tostring ()) Return
}
Player.tell ('+e.player.tostring ()+'@p])
Tellraw (Player, '[", {" text ":" @AT], "Bold": True, "color": "Gold"}, {"text": "'+player.tostration ()+'@"," Color ":" yellow "}]')
Playatsoundtoplayer (Player)
}
})
})
// Registration instructions/at
Onevent ("Command.regotion", event => {{{{{ Const {Commands: Commands, Arguments: Arguments} = Event;
Event.register (
Commands.litral ('at')
.Then (Commands.litral ('Setsound')
.Then (Commands.argument ('Soundindex', Arguments.integer.create (Event))
.Executes (ctx => {{
// const modeltype = Arguments.string.getResult (CTX, 'ModifyType')
Const soundEx = Arguments.integer.getResult (CTX, 'Soundindex')
Let Playerraw = CTX.Source.playerorexception
If (Playerraw == NULL) {
Console.info ("You can't execute this instruction on the server") Return 0
}
Let Player = Playerraw.askjs ()
Let soundinfo = soundlist [soundindex]
If (soundinfo! = Null) {
tellraw (player, '[", {" text ":"@at], "bold": true, "color": "gold"}, {"text": "Set@t effect to" "the sound effects to" "", "COLOR": "White"}, {"Text": "['+Soundinfo.soundname+']," color ":" Green "}]))
Player.persistentdata.atsound = soundinfo.SoundType player.persistentdata.atspeed = soundinfo.soundspeed
Playatsoundtoplayer (Player)
Return 1
} Else {
Utils.server.runcommandsilent ('PlaySound Minecraft: Block.anvil.land Music'+Player.tostring ()+'~ ~ ~ ~ 100 1 1')
Tellraw (Player, '[", {" text ":"@at], "Bold": true, "color": "Gold"}, {"text": "The index you entered is invalid!",, ","color": "red"}] ') Tellsoundlist (player, "red")
Return 1
}
})
Cure
Cure
.Then (Commands.litral ('Help')
.Executes (ctx => {{
Let Playerraw = CTX.Source.playerorexception
If (playerraw == null) {console.info ("You can't execute this instruction on the server")
Return 0
}
Let Player = Playerraw.askjs ()
Tellraw (Player, '[", {" text ":"@at], "Bold": true, "color": "Gold"}, {"text": "/at info", "color": "YELLOW"}, {"Text": "-", "COLOR": "White"}, {"text": "View your current@音 effect", "color": "green"}])))
tellraw (player, '[", {" text ":"@at], "bold": true, "color": "Gold"}, {"text": "/at soundlist", "color" "color": "YELLOW"}, {"text": "-", "color": "white"}, {"text": "View available sound list", "color": "green"}]) Tellraw (player, '["", {"Text": "@at]," bold ": true," color ":" Gold "}, {" text ":"/at setsound [Number] "," color "" color ": "YELLOW"}, {"text": "-", "color": "white"}, {"text": "Customly customize your@音", "color": "green"}]))
// All rights reserved, please keep the following field when modifying
Tellraw (Player, '[", {" text ":"@at], "Bold": True, "color": "Gold"}, {"text": "Powered by kubejs-coding: touchmear" "", "COLOR": "Gray"}] ')
Return 1
})
Cure
.Then (Commands.litral ('Soundlist')
.Executes (ctx => {{
Let Playerraw = CTX.Source.playerorexception
If (Playerraw == NULL) {
Console.info ("You can't execute this instruction on the server side")
Return 0
}
Let Player = Playerraw.askjs ()
Tellsoundlist (Player, "Green")
Return 1}
Cure
Cure
.Then (Commands.litral ('Info')
.Executes (ctx => {{
Let Playerraw = CTX.Source.playerorexception
If (Playerraw == NULL) {
Console.info ("You can't execute this instruction on the server side")
Return 0
}
Let Player = Playerraw.askjs ()
tellraw (player, '[", {" text ":"@at], "bold": true, "color": "Gold"}, {"text": "Listen, your@custom sound effects areThis- "," color ":" yellow "}] ') Playatsoundtoplayer (player)
Return 1
}
Cure
Cure
Cure
})
Function Tellsoundlist (player, color) {
Tellraw (Player, '[", {" text ":" @AT], "Bold": True, "color": "Gold"}, {"text": "The following is a list of sound effects","color": "'+color+'"}, {"text": "(click can be switched)", "color": "geay"}])
For (let i = 0; i
Let soundinfo = soundlist [i]
tellraw (player, '[", {" text ":"@at], "bold": true, "color": "Gold"}, {"text": "'+(i+1)++': ['+Soundinfo.Soundname+'], "UnderLined": True, "COLOR": "'+COLOR+'", "Clickevent": {"action": "run_command", "Value": "//"// "///"// "///at setsound '+i+' "}}] ')}}
}
Function settodefault (player) {
Player.persistentdata.atsound = 'Minecraft: block.bell.use'
Player.persistentdata.atspeed = 1.0
}
Function isplayEratingValid (Player) {{
Return Player.erSistentdata.atsound! = Null
}
Function Playatsoundtoplayer (player) {
If (!!! IsplayEratingValid (Player)) {
Settodefault (player)
}
Utils.server.runcommandsilent ('PlaySound'+Player.persistentdata.atsound+'Music'+Player.tostring ()+'~ ~ ~ ~ ~ ~ Player.persist ENTDATA.ATSPEED+'1')
}
Function Tellraw (Player, Contex) {{
Utils.server.runcommandsilent ('Tellraw'+Player.Tostring ()+"+Contex)
}