Paste #34786: Repo Script Ban Hammer

Date: 2016/07/13 21:28:17 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#~Banhammer Script v1 by Jumpsplat120
#
#/hammer, /bh or /banhammer to give yourself the Banhammer.
#I wouldn't suggest using it as a guide on how to code :p
#
#
HammerEvent:
    type: world
    events:
        #The hammer is a custom nether brick. Only usable if an OP, otherwise does literally nothing.
        on player damages entity with:HammerItem:
         - if <context.damager.is_op> {
          - if <context.damager> matches player {
           - if <context.entity> matches player {
            - flag <context.damager> banPlayer:<context.entity>
            - flag <context.damager> banPlayerName:<context.entity.name>
            - ban add <context.entity> "reason:You were hit with the banhammer!"
            - narrate "You banned <context.entity.name>! Right click with the banhammer to unban them."
            }
           }          
          }
         else {
          - determine cancelled
          }
        on player right clicks with HammerItem:
         - if <player.is_op> {
          - Narrate "You have unbanned <player.flag[banPlayerName]>."
          - ban remove <player.flag[banPlayer]>
          }
#The custom Hammer. If you want to change what it looks like, change the material
HammerItem:
    type: item
    #Change this if you want the item to look different
    material: i@nether_brick_item
    display name: <reset>Banhammer
    lore:
     - <reset>Left click to ban someone.
     - <reset>Right click to unban the most recent person.

#The command to give yourself the Ban Hammer. Only runs if you are OP.
Hammer Command:
  type: command
  name: Banhammer
  description: Run this command to give yourself the banhammer item. (Command & item does nothing if you are not OP'd)
  usage: /Banhammer OR /bh OR /hammer
  aliases: 
   - bh
   - hammer 
  script: 
      - if !<player.is_op||<context.server>> { 
       - narrate "<red>You do not have permission for that command." 
       - queue clear 
       }
      else {
       - give HammerItem
       }