Punish - Adding items to menu

Mar 21, 2016
Punish - Adding items to menu
  • In this tutorial I'll be showing you how to add items to the menu. For this example I will make 4 different Items that do the following:

    1.) When clicked will run commands via the console
    2.) When clicked will ban the target player (with title and subtitle)
    3.) When clicked will mute the target player (with actionbar)
    4.) When clicked will open another menu (in this case punish)


    First off, start by opening your menu file (tutorial.yml for me)



    Next we need to add the Contents section do so by added Contents:
    You should now have something like this:
    Code (Text):

    # The name of the menu, variables and colors supported.
    Title: 'Tutorial Menu'
    # The size of the menu, up to 54, must be divisible by 9 (9,18,27,36,45,54)
    Size: 9
    # Command used to open the menu (not required)
    Command: tutorial
    # Permission required to use the command
    Permission: tutorial.target
    # Set whether or not to use a target; If true command becomes /<command> <targetName> (e.g. /tutorial GrimReaper52498)
    UseTarget: true

    #Contents/Items
    Contents:
     


    From now on I will only be showing from that point below as the top part of the file is irrelevant to this tutorial.

    Next we need to define the item; In my case mine will be 'ban'.

    Code (Text):

    #Contents/Items
    Contents:
      ban:
     


    Now we need to define all the attributes for the item, I will do so now, and then explain each.

    Code (Text):

    #Contents/Items
    Contents:
      ban:
      ID: 166  
      SLOT: 2
      NAME: '&c&lBan &b&l%target_name%'
      ACTION: ban
      BAN_MESSAGE: '&c&lYou are banned. You can fill out an appeal at http://ourserverwebsite.com'
      TITLE_TO_PUNISHER: '&a&lPunishment Successful!'
      SUBTITLE_TO_PUNISHER: '&b&l%target_name% &c&lhas been banned!'
     


    Now that we have our first item made, let me break it down and tell you what everything is doing.

    ID: The id of the item to be displayed, in this case its 166; so that would be a barrier ingame
    SLOT: The slot in which the item should be placed within the menu
    NAME: The display name of the item
    ACTION: This defines what happens when the item is clicked. In our case ban.
    BAN_MESSAGE: The message displayed to the user on the disconnect screen and when they attempt to join while banned.
    TITLE_TO_PUNISHER: When the item is clicked it sends a title to the person issuing the punishment saying the defined message
    SUBTITLE_TO_PUNISHER: Same as above (wont work without the above)



    Now I will do the same for the next 3 items.


    Code (Text):

    #Contents/Items
    Contents:
      ban:
      ID: 166  
      SLOT: 2
      NAME: '&c&lBan &b&l%target_name%'
      ACTION: ban
      BAN_MESSAGE: '&c&lYou are banned. You can fill out an appeal at http://ourserverwebsite.com'
      TITLE_TO_PUNISHER: '&a&lPunishment Successful!'
      SUBTITLE_TO_PUNISHER: '&b&l%target_name% &c&lhas been banned!'
      consolecommands:
      ID: 137
      SLOT: 4
      NAME: '&c&lKill &b&l%target_name%'
      ACTION: command_console
      COMMANDS:
      - 'kill %target_name%'
      ACTIONBAR_TO_PUNISHER: '&a&lKilled &b&l%target_name%'
    punish:
      ID: 262
      SLOT: 6
      NAME: '&c&lOpen &b&lPunish'
      ACTION: menu
      MENU: punish
    tempmute:
      ID: 351
      DATA: 5
      SLOT: 8
      NAME: '&c&lMute &b&l%target_name%'
      ACTION: mute
      TIME: 10m
      ACTIONBAR: '&c&lYou have been muted for %punish_mute_time_formatted%!'
      ACTIONBAR_TO_PUNISHER: '&a&lMuted &b&l%target_name%'
     
    There. Now save the file and restart your server, when you open the menu the items should be there, test their functionality by clicking on one!



    All available item options can be found here & variables here!
  • Loading...
  • Loading...