Paste #34752: Edit of P#34750 Simple Cuboid

Date: 2016/07/12 12:44:27 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#Simple cuboid by sander758
#
#Permissions
#   /ctool      - simplecuboid.tool
#   /cpreview   - simplecuboid.preview
#   /cnew       - simplecuboid.new
#   /clist      - simplecuboid.list
#   /cremove    - simplecuboid.remove
#   /cteleport  - simplecuboid.teleport
cuboid_tool:
    type: item
    material: i@stone_axe
    display name: <gold>Cuboid Tool
    lore:
    - "<gray>Left click to set postion 1"
    - "<gray>Right click to set postion 2"

cuboid_events:
    type: world
    debug: false
    events:
        on system time hourly:
        - webget "http://morphanone.space/webizen.aspx/tracker?script=63&version=1"
        on system time minutely:
        - execute as_server "denizen save"
        on chelp command:
        - determine passively FULFILLED
        - narrate "<gold>Simple cuboid plugin by sander758"
        - narrate "<yellow> - /chelp <gray>Displays the cuboid commands"
        - narrate "<yellow> - /ctool <gray>Get the tool"
        - narrate "<yellow> - /cpreview <gold>(<yellow>name<gold>) <gray>Shows the outline of the specified cuboid. If no cuboid specified the outline of the current selected locations will be visible"
        - narrate "<yellow> - /cnew <gold>[<yellow>name<gold>] <gray>Create a new cuboid"
        - narrate "<yellow> - /clist <gold>[<yellow>number<gold>] <gray>List of all cuboids"
        - narrate "<yellow> - /cremove <gold>[<yellow>name<gold>] <gray>Remove a cuboid"
        - narrate "<yellow> - /cteleport <gold>[<yellow>name<gold>] <gray>Teleport to the center of the specified cuboid"
        on ctool command:
        - determine passively FULFILLED
        - if <player.is_op> || <player.has_permission[simplecuboid.tool]> {
            - give cuboid_tool qty:1
            - narrate "<gold>Giving cuboid tool"
        } else {
            - narrate "<red>You dont have permission for that command!"
        }
        on cpreview command:
        - determine passively FULFILLED
        - if <player.is_op> || <player.has_permission[simplecuboid.preview]> {
            - if <context.args.get[1]||nope> == nope {
                - if <pl.has_flag[cuboidToolLoc1]> && <pl.has_flag[cuboidToolLoc2]> {
                    - if <pl.flag[cuboidToolLoc1].as_location.world> == <pl.flag[cuboidToolLoc2].as_location.world> {
                        - narrate "<gold>Displaying the outline of the current selected locations"
                        - define loc1 <pl.flag[cuboidToolLoc1].as_location>
                        - define loc2 <pl.flag[cuboidToolLoc2].as_location>
                        - define locations <cu@%loc1%|%loc2%.outline>
                        - async {
                            - repeat 5 {
                                - foreach <def[locations]> {
                                    - playeffect <def[value].as_location.add[0.5,-0.5,0.5]> effect:red_dust data:0 offset:0 qty:1
                                }
                                - wait 10t
                            }
                        }
                    } else {
                        - narrate "<dark_red>Error: <red>Please select 2 locations in the same world"
                    }
                } else {
                    - narrate "<dark_red>Error: <red>Please select 2 valid locations"
                }
            } else {
                - if <context.args.get[1].as_cuboid.notable_name||nope> == nope {
                    - narrate "<dark_red>Error: <red><context.args.get[1]> doesnt exist"
                } else {
                    - narrate "<gold>Displaying the outline of <yellow><context.args.get[1]>"
                    - define locations <context.args.get[1].as_cuboid.outline>
                    - async {
                        - repeat 5 {
                            - foreach <def[locations]> {
                                - playeffect <def[value].as_location.add[0.5,-0.5,0.5]> effect:red_dust data:0 offset:0 qty:1
                            }
                            - wait 10t
                        }
                    }
                }

            }
        } else {
            - narrate "<red>You dont have permission for that command!"
        }
        on cnew command:
        - determine passively FULFILLED
        - if <player.is_op> || <player.has_permission[simplecuboid.new]> {
            - if <context.args.get[1]||nope> == nope {
                - narrate "<dark_red>Error: <red>No cuboid name specified"
            } else {
                - if <pl.has_flag[cuboidToolLoc1]> && <pl.has_flag[cuboidToolLoc2]> {
                    - if <pl.flag[cuboidToolLoc1].as_location.world> == <pl.flag[cuboidToolLoc2].as_location.world> {
                        - if <context.args.get[1].as_cuboid.notable_name||nope> == nope {
                            - narrate "<gold>Created a new cuboid as <red><context.args.get[1]>"
                            - note cu@<pl.flag[cuboidToolLoc1].split[l@].get[2]>|<pl.flag[cuboidToolLoc2].split[l@].get[2]> as:<context.args.get[1]>
                        } else {
                            - narrate "<dark_red>Error: <red>That name already exists"
                        }
                    } else {
                        - narrate "<dark_red>Error: <red>Please select 2 locations in the same world"
                    }
                } else {
                    - narrate "<dark_red>Error: <red>Please select 2 valid locations"
                }
            }
        } else {
            - narrate "<red>You dont have permission for that command!"
        }
        on clist command:
        - determine passively FULFILLED
        - if <player.is_op> || <player.has_permission[simplecuboid.list]> {
            - narrate "<gold>Amount of cuboids: <yellow><server.list_notables[cuboids].size>"
            - narrate "<gold>List:"
            - define page <context.args.get[1]||1>
            - define first <def[page].mul_int[10].add_int[1].sub_int[10]>
            - define last <def[page].mul_int[10]>
            - foreach <server.list_notables[cuboids].alphanumeric.get[%first%].to[%last%]> {
                - narrate "<yellow>- <def[value].split[cu@].get[2]>"
            }
            - narrate "<gold>Page <yellow><context.args.get[1]||1><gold> of <yellow><server.list_notables[cuboids].size.div_int[10].add_int[1]> <gold>/clist [<yellow>number<gold>]"
        } else {
            - narrate "<red>You dont have permission for that command!"
        }
        on cremove command:
        - determine passively FULFILLED
        - if <player.is_op> || <player.has_permission[simplecuboid.remove]> {
            - if <context.args.get[1]||nope> == nope {
                - narrate "<dark_red>Error: <red>No cuboid name specified"
            } else {
                - if <context.args.get[1].as_cuboid.notable_name||nope> == nope {
                    - narrate "<dark_red>Error: <red><context.args.get[1]> doesnt exist"
                } else {
                    - narrate "<gold>Removed <red><context.args.get[1]><gold> cuboid"
                    - note remove as:<context.args.get[1].as_cuboid.notable_name>
                }
            }
        } else {
            - narrate "<red>You dont have permission for that command!"
        }
        on cteleport command:
        - determine passively FULFILLED
        - if <player.is_op> || <player.has_permission[simplecuboid.teleport]>  {
            - if <context.args.get[1]||nope> == nope {
                - narrate "<dark_red>Error: <red>No cuboid name specified"
            } else {
                - if <context.args.get[1].as_cuboid.notable_name||nope> == nope {
                    - narrate "<dark_red>Error: <red><context.args.get[1]> doesnt exist"
                } else {
                    - narrate "<gold>Teleporting to the center of <yellow><context.args.get[1]>"
                    - teleport <context.args.get[1].as_cuboid.center>
                }
            }
        } else {
            - narrate "<red>You dont have permission for that command!"
        }

        on player right clicks block with cuboid_tool:
        - narrate "<gold>Set location 2 on <context.location>"
        - flag player cuboidToolLoc2:<context.location>
        on player left clicks block with cuboid_tool:
        - narrate "<gold>Set location 1 on <context.location>"
        - flag player cuboidToolLoc1:<context.location>

        on player breaks block:
        - if <pl.item_in_hand.simple> == i@CUBOID_TOOL {
            - determine passively CANCELLED
        }