Jump to content

Kick thingy


ApexSplat

Recommended Posts

Created this piece of code. Will probably add more features including bans and the history of bans as well as making it be a multiple page history instead of just a singular page. Also when looking at history, green terracotta means they were kicked with a reason and red means they weren't. NR stands for No Reason and R stands for Reason.

Update 1:

- Some fixes

- Added warns

- Changed permissions from kick prefix to punish prefix

Permissions:

- punish.kick.bypass - player can't be kicked

- punish.warn.bypass - player can't be warned

- punish.kick.notify - notifies player of when someone is kicked

- punish.warn.notify - notifies player of when someone is warned

- punish.kick - allows player to kick someone

- punish.warn - allows player to warn someone

- punish.history - view the history of specified player

options:
    pre: &8[&aPunish&8]

function guiPunish(p: player, tag: string, name: string, perm: string):
    set metadata tag {_tag} of {_p} to chest inventory with 6 rows named {_name}
    set slot 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52 and 53 of metadata tag {_tag} of {_p} to black stained glass pane
    set {_slot} to 10
    loop all players:
        if loop-player has permission {_perm}:
            set slot {_slot} of metadata tag {_tag} of {_p} to loop-player's skull named "&6&l%loop-player%"
            add 1 to {_slot}
    open (metadata tag {_tag} of {_p}) to {_p}

function historyPlayer(p: player, tag: string, name: string, perm: string, list: objects):
    set metadata tag {_tag} of {_p} to chest inventory with 6 rows named {_name}
    set slot 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 26, 27, 35, 36, 44, 45, 46, 47, 48, 49, 50, 51, 52 and 53 of metadata tag {_tag} of {_p} to black stained glass pane
    set {_slot} to 10
    loop {_list::*}:
        if loop-value contains "&bR":
            if {_p} has permission {_perm}:
                set slot {_slot} of metadata tag {_tag} of {_p} to green concrete named "%loop-value%" with lore "", "&aLEFT CLICK - View in chat" and "&cRIGHT CLICK - Clear kick from history"
                add 1 to {_slot}
            else:
                set slot {_slot} of metadata tag {_tag} of {_p} to green concrete named "%loop-value%" with lore "" and "&aLEFT CLICK - View in chat"
                add 1 to {_slot}
        else if loop-value contains "&bNR":
            if {_p} has permission {_perm}:
                set slot {_slot} of metadata tag {_tag} of {_p} to red concrete named "%loop-value%" with lore "", "&aLEFT CLICK - View in chat" and "&cRIGHT CLICK - Clear kick from history"
                add 1 to {_slot}
            else:
                set slot {_slot} of metadata tag {_tag} of {_p} to red concrete named "%loop-value%" with lore "" and "&aLEFT CLICK - View in chat"
                add 1 to {_slot}
    open (metadata tag {_tag} of {_p}) to {_p}

command /kick:
    trigger:
        if player has permission "punish.kick":
            guiPunish(player, "kick", "&6&lKick", "punish.kick.bypass")
        else:
            send "Uknown command. Type ""/help"" for help"

command /warn:
    trigger:
        if player has permission "punish.warn":
            guiPunish(player, "warn", "&c&lWarn", "punish.warn.bypass")
        else:
            send "Uknown command. Type ""/help"" for help"

command /history [<offline player>]:
    trigger:
        if player has permission "punish.history":
            if arg 1 is set:
                set {history::%player%} to arg 1
                set metadata tag "history" of player to chest inventory with 3 rows named "&6&l%{history::%player%}%&6&l's History"
                set slot 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 17, 18, 19, 20, 21, 22, 23, 24, 25 and 26 of metadata tag "history" of player to black stained glass pane
                set slot 10 of metadata tag "history" of player to red concrete named "&c&lWarns"
                set slot 11 of metadata tag "history" of player to orange concrete named "&6&lKicks"
                open (metadata tag "history" of player) to player
            else:
                send "{@pre} &aNo player was specified"
        else:
            send "Uknown command. Type ""/help"" for help"

on inventory click:
    if event-inventory = (metadata tag "kick" of player):
        if event-slot isn't air:
            if event-slot isn't black stained glass pane:
                cancel event
                delete {kick::%player%::reason}
                close player's inventory
                set {kick::%player%::name} to name of event-slot
                replace all "&6&l" in {kick::%player%::name} with ""
                set {kick::%player%::reason} to 10
                send "{@pre} &aType the reason in chat!"
                loop 10 times:
                    wait 1 second
                    remove 1 from {kick::%player%::reason}
                if {kick::%player%::name} is set:
                    kick ({kick::%player%::name} parsed as player) due to "Kicked!"
                    add "&bNR - &a%player% &8kicked &a%{kick::%player%::name}%&b - %now%" to {kicks::%{kick::%player%::name}%::*}
                    send "{@pre} &a%player% &8kicked &a%{kick::%player%::name}%&8!" to all players where [input has permission "punish.kick.notify"]
                delete {kick::%player%::reason}
                delete {kick::%player%::name}
    if event-inventory = (metadata tag "warn" of player):
        if event-slot isn't air:
            if event-slot isn't black stained glass pane:
                cancel event
                delete {warn::%player%::reason}
                close player's inventory
                set {warn::%player%::name} to name of event-slot
                replace all "&6&l" in {warn::%player%::name} with ""
                set {warn::%player%::reason} to 10
                send "{@pre} &aType the reason in chat!"
                loop 10 times:
                    wait 1 second
                    remove 1 from {warn::%player%::reason}
                if {warn::%player%::name} is set:
                    send "{@pre} &8No reason was given so &a%{warn::%player%::name}% &8wasn't warned"
                delete {warn::%player%::reason}
                delete {warn::%player%::name}
    if event-inventory = (metadata tag "history" of player):
        cancel event
        if index of event-slot is 10:
            historyPlayer(player, "historyWarns", "&c&l%{history::%player%}%&c&l's Warns", "punish.warn.clear", {warns::%{history::%player%}%::*})
        if index of event-slot is 11:
            historyPlayer(player, "historyKicks", "&6&l%{history::%player%}%&6&l's Kicks", "punish.kick.clear", {kicks::%{history::%player%}%::*})
    if event-inventory = (metadata tag "historyKicks" of player):
        cancel event
        if click action is left mouse button:
            if event-slot isn't air:
                if event-slot isn't black stained glass pane:
                    send "%name of event-slot%"
        else if click action is right mouse button:
            if player has permission "punish.kick.clear":
                if event-slot isn't air:
                    if event-slot isn't black stained glass pane:
                        remove "%name of event-slot%" from {kicks::%{history::%player%}%::*}
                        send "{@pre} &aCleared %name of event-slot% &afrom %{history::%player%}%&a's history"
                        historyPlayer(player, "historyKicks", "&6&l%{history::%player%}%&6&l's Kicks", "punish.kick.clear", {kicks::%{history::%player%}%::*})
    if event-inventory = (metadata tag "historyWarns" of player):
        cancel event
        if click action is left mouse button:
            if event-slot isn't air:
                if event-slot isn't black stained glass pane:
                    send "%name of event-slot%"
        else if click action is right mouse button:
            if player has permission "punish.warn.clear":
                if event-slot isn't air:
                    if event-slot isn't black stained glass pane:
                        remove "%name of event-slot%" from {warns::%{history::%player%}%::*}
                        send "{@pre} &aCleared %name of event-slot% &afrom %{history::%player%}%&a's history"
                        historyPlayer(player, "historyWarns", "&c&l%{history::%player%}%&c&l's Warns", "punish.warn.clear", {warns::%{history::%player%}%::*})

on chat:
    if {kick::%player%::reason} is set:
        cancel event
        kick ({kick::%player%::name} parsed as player) due to "%message%"
        add "&bR - &a%player% &8kicked &a%{kick::%player%::name}%&8 for &a%message%&b - %now%" to {kicks::%{kick::%player%::name}%::*}
        send "{@pre} &a%player% &8kicked &a%{kick::%player%::name}%&8 for &a%message%&8!" to all players where [input has permission "punish.kick.notify"]
        delete {kick::%player%::name}
    if {warn::%player%::reason} is set:
        cancel event
        send "{@pre} &cYou have been warned for &a%message%" to {warn::%player%::name}
        send "{@pre} &a%player% &8warned &a%{warn::%player%::name}%&8 for &a%message%&8!" to all players where [input has permission "punish.warn.notify"]
        add "&bR - &a%player% &8warned &a%{warn::%player%::name}%&8 for &a%message%&b - %now%" to {warns::%{warn::%player%::name}%::*}
        delete {warn::%player%::name}

 

Edited by ApexSplat

Discord: Dead#6905

Love anime!


Anime Gifs

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...