FFA plugin fix

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

zKiita

Member
Dec 5, 2020
3
0
1
The plugin is functional medium in Minecraft 1.16.4. The thing is that the / FFA setEnable and the / FFA leave do not work, so I would like someone to help me fix it please...

Code:
import:
    java.lang.Math
    java.util.Arrays
    java.util.ArrayList   
    org.bukkit.Sound
    org.bukkit.material.MaterialData       
    org.bukkit.Bukkit   
    org.bukkit.event.block.BlockFromToEvent
    fr.mrmicky.fastparticle.FastParticle
    fr.mrmicky.fastparticle.ParticleType   
    org.bukkit.event.player.PlayerInteractEvent
    org.bukkit.event.player.PlayerToggleFlightEvent
    org.bukkit.event.player.PlayerArmorStandManipulateEvent   
    
options:

    #do not touch this -_-
    plugin-version: 1.0.0


local effect create scoreboard for %player%:   
    trigger:
        if {-FFA::cache::TitleManager}.hasScoreboard(expr-1) is true:
            {-FFA::cache::TitleManager}.removeScoreboard(expr-1)
        {-FFA::cache::TitleManager}.giveScoreboard(expr-1)

local effect delete scoreboard of %player%:   
    trigger:
        {-FFA::cache::TitleManager}.removeScoreboard(expr-1)   

local effect set scoreboard title of %player% to %string%:   
    trigger:
        {-FFA::cache::TitleManager}.setScoreboardTitle(expr-1 and expr-2)

local effect set scoreboard line %number% of %player% to %string%:   
    trigger:
        {-FFA::cache::TitleManager}.setScoreboardValue(expr-2, expr-1 and expr-3)

function check_yaml(dir: text, value: text, set: text, type: text = "TEXT"):
    yaml value {_value} from "leaf.ffa.%{_dir}%" is not set:
        if {_type} is "text":
            set yaml value {_value} from "leaf.ffa.%{_dir}%" to {_set}
        if {_type} is "number":
            set yaml value {_value} from "leaf.ffa.%{_dir}%" to {_set} parsed as number
        if {_type} is "boolean":
            set yaml value {_value} from "leaf.ffa.%{_dir}%" to {_set} parsed as boolean
    if {_type} is "list":
        yaml list {_value} from "leaf.ffa.%{_dir}%" is not set
        loop {_set} split at "||":
            add loop-value to yaml list {_value} from "leaf.ffa.%{_dir}%"

expression %item% with [leaf] lore %texts%:
    return type: item
    get:
        set {_r} to expr-1
        loop expressions 2:
            set {_lore} to loop-value-1
            add 1 to {_line}           
            set line {_line} of lore of {_r} to colored {_lore}       
        return {_r}

#From https://forums.skunity.com/resources/mirrorutils.706/ by EWS
local expression replacer %texts% with %texts% in %text%:
    return type: text
    get:
        set {_result} to expr-3
        loop exprs-1:
            add 1 to {_n}
            replace all "%loop-value-1%" with ({_n}th element of exprs-2 ? "") in {_result}
        return {_result}           

on load:
    loop currently loaded yaml files:
        loop-value contains "leaf.ffa.config" or "leaf.ffa.playerdata"
        unload yaml loop-value-1
    loop "config" and "data":
        load yaml "plugins/LeafFFA/%loop-value-1%.yml" as "leaf.ffa.%loop-value-1%"   
    check_yaml("config", "Settings.ChatFormat", "&a{kills} &8✦ &7{player} &8» &7{message}")       
    check_yaml("config", "Settings.PointsPerKill", "5", "number")   
    check_yaml("config", "Settings.LosePointsOnDeath", "3", "number")   
    check_yaml("config", "Settings.RemoveBlockDelay", "3 seconds")                               
    check_yaml("config", "Scoreboard.Name", "&8︼︼ &eFFA &8︼︼")     
    check_yaml("config", "Scoreboard.Lines", "&7{now}||||&7➥ &fYour Status ⤵||||&8▪ &fKills: &a{Kills}||&8▪ &fPoints: &a{Points}||&8▪ &fDeaths: &a{Deaths}||||&7➥ &fServer Status ⤵||||&8╔ &e&nMode&r: {arena}||&8╚ &e&nOnline&r: {playerCount}||||&eplay.my-cool-server.net", "list")       
    check_yaml("config", "Messages.Join", "&7{player} &ejoined.")   
    check_yaml("config", "Messages.Leave", "&7{player} &eleft.")
    check_yaml("config", "Messages.Death", "&c➜ {victim} &7died")   
    check_yaml("config", "Messages.Killed", "&c➜ {victim} &7was killed by {killer}")               
    loop "config" and "data":       
        save yaml "leaf.ffa.%loop-value-1%"   
                                            
command ffa [<text = help>] [<text>]:
    executable by: players
    trigger:
        if arg-1 is "help":
            send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
            send "&a/ffa join &8(&7arena_name&8)"       
            send "&a/ffa autojoin"
            send "&a/ffa leave"
            send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
            if player has permission "ffa.admin":       
                send "&e/ffa createArena &8(&7arena_name&8)"                                               
                send "&e/ffa setSpawn &8(&7arena_name&8)"           
                send "&e/ffa setInventory &8(&7arena_name&8)"
                send "&e/ffa setEnable &8(&7arena_name&8)"               
                send "&e/ffa setLeave"               
                send centered "&7☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁☁" to player
                stop
        if arg-1 is "join":       
            if {-FFA::cache::player::%player%::state} is set:
                stop
            if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is "ready":
                ffa_join(player, arg-2)       
        if arg-1 is "createArena":
            if player has permission "ffa.admin":   
                if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
                    send "&cThis arena is already created."   
                    stop
                set yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" to "created"
                send "&aArena &b%arg-2%&a created."           
                save yaml "leaf.ffa.data"   
        if arg-1 is "setSpawn":
            if player has permission "ffa.admin":       
                if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
                    set yaml value "Arenas.%arg-2%.Spawn" from "leaf.ffa.data" to location of player
                    send "&aSpawn location Set for arena &b%arg-2%."
                    save yaml "leaf.ffa.data"   
                else:
                    send "&eThere is no arena called like this."       
        if arg-1 is "setInventory":
            if player has permission "ffa.admin":       
                if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
                    set {_int} to 0
                    loop 36 times:
                        if slot {_int} of player's inventory != air:
                            set yaml value "Arenas.%arg-2%.Inventory.%{_int}%" from "leaf.ffa.data" to slot {_int} of player's inventory
                        add 1 to {_int}
                    set yaml value "Arenas.%arg-2%.Inventory.Helmet" from "leaf.ffa.data" to player's helmet
                    set yaml value "Arenas.%arg-2%.Inventory.Chestplate" from "leaf.ffa.data" to player's chestplate
                    set yaml value "Arenas.%arg-2%.Inventory.Leggings" from "leaf.ffa.data" to player's legging
                    set yaml value "Arenas.%arg-2%.Inventory.Boots" from "leaf.ffa.data" to player's boots   
                    send "&aInventory for arena &b%arg-2% &asaved."   
                    save yaml "leaf.ffa.data"
                else:
                    send "&eThere is no arena called like this."
        if arg-1 is "enableArena":
            if player has permission "ffa.admin":   
                if yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" is set:
                    set yaml value "Arenas.%arg-2%.State" from "leaf.ffa.data" to "ready"
                    send "&aArena &b%arg-2% &aenabled."
                    save yaml "leaf.ffa.data"
                else:
                    send "&eThere is no arena called like this."                   
        if arg-1 is "setLeave":
            if player has permission "ffa.admin":   
                set yaml value "Locations.Leave" from "leaf.ffa.data" to location of player
                send "&aLeave location set."   
                save yaml "leaf.ffa.data"                                       

on load:
    loop all players:
        if {-FFA::cache::player::%loop-player%::state} is set:
            ffa_leave({_p})
    delete {-FFA::cache::*}
    send "&7&l--------------------------------------------" to console
    send " " to console
    send "&aLoading &ev.{@plugin-version}&a..." to console
    broadcast "&aLeafFFA loaded!"
    send " " to console
    send "&7&l--------------------------------------------" to console
    set {-FFA::cache::BlockDelay} to yaml value "Settings.RemoveBlockDelay" from "leaf.ffa.config" parsed as timespan
    set {-FFA::cache::TitleManager} to Bukkit.getServer().getPluginManager().getPlugin("TitleManager")   
    loop yaml nodes with keys "Arenas" from "leaf.ffa.data":
        loop {FFA::cache::arena::%loop-value-1%::Blocks::*}:
            set block at loop-value-2 to air
            add 1 to {_int}
            if {_int} = 20:
                set {_int} to 0
                wait a tick
        add world of yaml value "Arenas.%loop-value-1%.Spawn" from "leaf.ffa.data" to {-FFA::cache::Worlds::*}

on unload:
    send "&7&l--------------------------------------------" to console
    send " " to console
    send "&aDisabling &ev.{@plugin-version}&a..." to console
    send "&ev.{@plugin-version} &adisabled!" to console
    send " " to console
    send "&7&l--------------------------------------------" to console

function ffa_stats(p: player, do: text, type: text = "check", amount: number = 1):
    if yaml "leaf.ffa.playerdata.%uuid of {_p}%" is not loaded:
        load yaml "plugins/LeafFFA/playerdata/%uuid of {_p}%.yml" as "leaf.ffa.playerdata.%uuid of {_p}%"   
    {_do} is "check":
        loop "Points", "Kills" and "Deaths":
            if yaml value "Stats.%loop-value-1%" from "leaf.ffa.playerdata.%uuid of {_p}%" is not set:
                set yaml value "Stats.%loop-value-1%" from "leaf.ffa.playerdata.%uuid of {_p}%" to 0
    {_do} is "add":
        set yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" to yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" + {_amount}
    {_do} is "remove":
        set yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" to yaml value "Stats.%{_type}%" from "leaf.ffa.playerdata.%uuid of {_p}%" - {_amount}       
    save yaml "leaf.ffa.playerdata.%uuid of {_p}%"

function ffa_play_sound(p: player, soundLegacy: string, soundNew: string):
    if minecraft version contains "1.8":
        {_p}.playSound(location of {_p}, Sound..{_soundLegacy}, 1 and 1)   
    else:   
        {_p}.playSound(location of {_p}, Sound..{_soundNew}, 1 and 1)   

on quit:
    if {-FFA::cache::player::%player%::state} is set:
        ffa_leave(player)
                    
on break:
    if {-FFA::cache::player::%player%::state} is set:
        if {FFA::cache::arena::%{-FFA::cache::player::%player%::state}%::Blocks::%location of event-block%} is set:
            stop
        cancel event
            
on place:
    if {-FFA::cache::player::%player%::state} is set:
        set {_w} to world of player
        set {FFA::cache::arena::%{-FFA::cache::player::%player%::state}%::Blocks::%location of event-block%} to location of event-block
        wait {-FFA::cache::BlockDelay}
        set event-block to air
        FastParticle.spawnParticle({_w}, ParticleType.FLAME, location of event-block and 1)

on PlayerArmorStandManipulateEvent:
    if {-FFA::cache::player::%event.getPlayer()%::state} is set:   
        cancel event

on PlayerInteractEvent:
    if {-FFA::cache::player::%event.getPlayer()%::state} is set:   
        if "%event.getAction()%" is "PHYSICAL":
            cancel event
    
on chat:
    if {-FFA::cache::player::%player%::state} is set:
        set {_format} to replacer "{player}" and "{message}" with "%player%" and message in yaml value "Settings.ChatFormat" from "leaf.ffa.config"
        loop "Points", "Kills" and "Deaths":
            set {_int} to yaml value "Stats.%loop-value-1%" from "leaf.ffa.playerdata.%uuid of player%"
            replace all "{%loop-value-1%}" with "%{_int}%" in {_format}
        set chat format to {_format}
        set chat recipients to {-FFA::cache::arena::%{-FFA::cache::player::%player%::state}%::players::*}

on drop:
    if {-FFA::cache::player::%player%::state} is set:
        cancel event

on hunger bar change:   
    if {-FFA::cache::player::%player%::state} is set:
        set player's hunger to 20

function ffa_join(p: player, arena: text):
    yaml value "Arenas.%{_arena}%.State" from "leaf.ffa.data" is "ready"
    ffa_stats({_p}, "check")
    ffa_clear_player({_p})
    set {-FFA::cache::player::%{_p}%::state} to {_arena}
    teleport {_p} to yaml value "Arenas.%{_arena}%.Spawn" from "leaf.ffa.data"
    set {_int} to 0
    loop 36 times:
        yaml value "Arenas.%{_arena}%.Inventory.%{_int}%" from "leaf.ffa.data" is set:
            set slot {_int} of {_p}'s inventory to yaml value "Arenas.%{_arena}%.Inventory.%{_int}%" from "leaf.ffa.data"
        add 1 to {_int}
    set {_p}'s helmet to yaml value "Arenas.%{_arena}%.Inventory.Helmet" from "leaf.ffa.data"
    set {_p}'s chestplate to yaml value "Arenas.%{_arena}%.Inventory.Chestplate" from "leaf.ffa.data"
    set {_p}'s legging to yaml value "Arenas.%{_arena}%.Inventory.Leggings" from "leaf.ffa.data"
    set {_p}'s boots to yaml value "Arenas.%{_arena}%.Inventory.Boots" from "leaf.ffa.data"
    ffa_createBoard({_p})
    add {_p} to {-FFA::cache::arena::%{_arena}%::players::*}
    send replacer "{player}" with {_p}'s display name in yaml value "Messages.Join" from "leaf.ffa.config" to {-FFA::cache::arena::%{-FFA::cache::player::%{_p}%::state}%::players::*}

function ffa_leave(p: player):
    ffa_clear_player({_p})
    send replacer "{player}" with {_p}'s display name in yaml value "Messages.Leave" from "leaf.ffa.config" to {-FFA::cache::arena::%{-FFA::cache::player::%{_p}%::state}%::players::*}
    delete {-FFA::cache::player::%{_p}%::*}
    teleport {_p} to yaml value "Locations.Leave" from "leaf.ffa.data"
    unload yaml "leaf.ffa.playerdata.%uuid of {_p}%"

function ffa_show_blood(p: player):
    set {_w} to world of {_p}
    set {_loc} to location of {_p}
    set {_material} to new MaterialData(Material.."REDSTONE_BLOCK")
    FastParticle.spawnParticle({_w}, ParticleType.BLOCK_CRACK, {_loc}, 3 and {_material})

function ffa_player_death(p: player):
    set {_killer} to "%metadata value ""FFA_KILLER"" of {_p}%" parsed as player
    ffa_stats({_p}, "add", "Deaths")
    ffa_stats({_p}, "remove", "Deaths", yaml value "Settings.LosePointsOnDeath" from "leaf.ffa.config")
    if {_killer} is set:
        ffa_stats({_killer}, "add", "Kills")
        send replacer "{victim}" and "{killer}" with "%{_p}%" and "%{_killer}%" in yaml value "Messages.Killed" from "leaf.ffa.config" to {-FFA::cache::arena::%{-FFA::cache::player::%{_p}%::state}%::players::*}
    else:
        send replacer "{victim}" with "%{_p}%" in yaml value "Messages.Death" from "leaf.ffa.config" to {-FFA::cache::arena::%{-FFA::cache::player::%{_p}%::state}%::players::*}
    teleport {_p} to yaml value "Arenas.%{-FFA::cache::player::%{_p}%::state}%.Spawn" from "leaf.ffa.data"
    ffa_play_sound({_p}, "ANVIL_BREAK", "BLOCK_ANVIL_BREAK")
    ffa_play_sound({_killer}, "LEVEL_UP", "ENTITY_PLAYER_LEVELUP")

on damage of player:
    if {-FFA::cache::player::%victim%::state} is set:
        ffa_show_blood(victim)
        if attacker is player:
            set metadata value "FFA_KILLER" of victim to attacker
        if damage >= health of victim:
            cancel event   
            ffa_player_death(victim)                   
                            
function ffa_clear_player(p: player):                       
    heal {_p}
    extinguish {_p}
    set {_p}'s food to 20   
    clear {_p}'s level
    clear {_p}'s inventory
    {_p}.setFlying(false)
    {_p}.setAllowFlight(false)   
    set {_p}'s gamemode to survival
    loop ...{_p}.getActivePotionEffects():
        {_p}.removePotionEffect(loop-value.getType())   
    set velocity of {_p} to new vector 0, 0, 0   

function ffa_setSlot(p: player, slot: number, t: text):
    add "&a", "&b", "&c", "&d", "&e", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9" and "&f" to {_d::*}
    if {_slot} is between 1 and 15:
        set scoreboard line {_slot} of {_p} to "%{_d::%{_slot}%}%%{_t}%"       
    
function ffa_createBoard(p: player):
    create scoreboard for {_p}
    add "&a", "&b", "&c", "&d", "&e", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9" and "&f" to {_d::*}   
    set scoreboard title of {_p} to yaml value "Scoreboard.Name" from "leaf.ffa.config"
    while {-FFA::cache::player::%{_p}%::state} is set:
        set {_slot} to 0   
        set {_playerCount} to 0
        loop all players:
            if {-FFA::cache::player::%loop-player%::state} is {-FFA::cache::player::%{_p}%::state}:
                add 1 to {_playerCount}
        loop yaml list "Scoreboard.Lines" from "leaf.ffa.config":
            set {_value} to "%loop-value-1%"           
            replace all "{now}" with "%now%" in {_value}
            replace all "{playerCount}" with "%{_playerCount}%" in {_value}   
            replace all "{arena}" with "%{-FFA::cache::player::%{_p}%::state}%" in {_value}               
            loop "Points", "Kills" and "Deaths":
                set {_int} to yaml value "Stats.%loop-value-2%" from "leaf.ffa.playerdata.%uuid of {_p}%"
                replace all "{%loop-value-2%}" with "%{_int}%" in {_value}                           
            ffa_setSlot({_p}, {_slot}, colored {_value})
            add 1 to {_slot}                       
        wait a second

on BlockFromToEvent:
    if "%event.getToBlock().getType()%" contains "cobblestone" or "obsidian":
        if {-FFA::cache::Worlds::*} contains "%event.getToBlock().getWorld()%":
            cancel event
 
Any errors?
Aren't you missing the slash (/) before the command? (line 91) If it's right then I'm sorry, I have never done it like so.
 
[QUOTE = "Nikd0, publicación: 54317, miembro: 11341"] ¿Algún error?
¿No te falta la barra ( / ) antes del comando? (línea 91) Si está bien, lo siento, nunca lo había hecho así. [/ QUOTE]

Si lo uso, pero no pasa nada. No funciona
 
[QUOTE = "Nikd0, publicación: 54317, miembro: 11341"] ¿Algún error?
¿No te falta la barra ( / ) antes del comando? (línea 91) Si está bien, lo siento, nunca lo había hecho así. [/ QUOTE]

Si lo uso, pero no pasa nada. No funciona
Does it give you any errors?
 
Status
Not open for further replies.