Initial commit

This commit is contained in:
Rares Bozga
2025-11-29 22:53:32 +02:00
parent e9fa13dbd3
commit 461e95114c
157 changed files with 7597 additions and 1 deletions

View File

@@ -0,0 +1,147 @@
apartments_command_apartmentaddmember:
debug: false
type: command
name: apartmentaddmember
description: Add a member to the apartment you are currently in.
usage: /apartmentaddmember (player)
aliases:
- aptaddmember
- aptam
permission: apartments.command.apartmentaddmember
tab completions:
1: <server.online_players.parse[name]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- define apartment <proc[apartments_at].context[<player.location>]>
- if <[apartment]> == null:
- narrate "<&c>You can only use this command inside apartments."
- stop
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <player> != <[owner]>:
- narrate "<&c>You do not own this apartment!"
- stop
- if <context.args.size> <= 0:
- narrate "<&c>Invalid use. Please try /<context.alias> (player)"
- stop
- define target <server.match_offline_player[<context.args.get[1]>].if_null[null]>
- if <[target]> == null:
- narrate "<&c>A player with the username <context.args.get[1]> could not be found."
- stop
- if <[target]> == <player>:
- narrate "<&c>You cannot add yourself as a member!"
- stop
- run apartments_add_member def.apartment:<[apartment]> def.member:<[target]>
- narrate format:formats_prefix "<&a>Added <&7><[target].name> to your apartment (<&b>member<&7>)."
apartments_command_apartmentaddmoderator:
debug: false
type: command
name: apartmentaddmoderator
description: Adds a moderator to the apartment you are currently in.
usage: /apartmentaddmoderator (player)
aliases:
- aptaddmod
permission: apartments.command.apartmentaddmod
tab completions:
1: <server.online_players.parse[name]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- define apartment <proc[apartments_at].context[<player.location>]>
- if <[apartment]> == null:
- narrate "<&c>You can only use this command inside apartments."
- stop
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <player> != <[owner]>:
- narrate "<&c>You do not own this apartment!"
- stop
- if <context.args.size> <= 0:
- narrate "<&c>Invalid use. Please try /<context.alias> (player)"
- stop
- define target <server.match_offline_player[<context.args.get[1]>].if_null[null]>
- if <[target]> == null:
- narrate "<&c>A player with the username <context.args.get[1]> could not be found."
- stop
- if <[target]> == <player>:
- narrate "<&c>You cannot add yourself as a moderator!"
- stop
- run apartments_add_moderator def.apartment:<[apartment]> def.moderator:<[target]>
- narrate format:formats_prefix "<&a>Added <&7><[target].name> to your apartment (<&6>moderator<&7>)."
apartments_command_apartmentremoveaccess:
debug: false
type: command
name: apartmentremoveaccess
description: Removes all access for a player from the apartment you are currently in.
usage: /apartmentremoveaccess (player)
aliases:
- aptremoveaccess
- aptrm
permission: apartments.command.apartmentremoveaccess
tab completions:
# TODO: use the procedural tab-complete to handle this correctly!
1: <server.online_players.parse[name]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
- define apartment <proc[apartments_at].context[<player.location>]>
- if <[apartment]> == null:
- narrate "<&c>You can only use this command inside apartments."
- stop
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <player> != <[owner]>:
- narrate "<&c>You do not own this apartment!"
- stop
- if <context.args.size> <= 0:
- narrate "<&c>Invalid use. Please try /<context.alias> (player)"
- stop
- define target <server.match_offline_player[<context.args.get[1]>].if_null[null]>
- if <[target]> == null:
- narrate "<&c>A player with the username <context.args.get[1]> could not be found."
- stop
- if <[target]> == <player>:
- narrate "<&c>You cannot remove your own access!"
- stop
- if <[target].location.in_region[<[apartment].id>]>:
- run apartments_end_edit def.player:<[target]>
- run apartments_remove_access def.apartment:<[apartment]> def.member:<[target]>
- narrate format:formats_prefix "<&c>Removed <&7>member <[target].name> from your apartment."
apartments_command_apartmenteditmode:
debug: false
type: command
name: apartmenteditmode
description: Toggle edit mode for the apartment you are currently in.
usage: /apartmenteditmode
aliases:
- apteditmode
- editmode
permission: apartments.command.apartmenteditmode
tab completions:
1: <server.online_players.parse[name]>
script:
- if <context.source_type> != player:
- narrate "<&c>Please run this command as a player."
- stop
# toggle off
- if <player.has_flag[apartments_edit]>:
- run apartments_end_edit def.player:<player>
- narrate format:formats_prefix "<&e>Exiting <&6>Edit Mode..."
- stop
# toggle on
- define apartment <proc[apartments_at].context[<player.location>]>
- if <[apartment]> == null:
- narrate "<&c>You can only use this command inside apartments."
- stop
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <player> != <[owner]>:
- define access_level <proc[apartments_access_level].context[<player>|<player.location>]>
- if <[access_level]> != moderator:
- narrate "<&c>You must own this apartment or be an apartment moderator to enable editing here!"
- stop
- run apartments_begin_edit def.apartment:<[apartment]> def.player:<player>
- narrate format:formats_prefix "<&a>Entering <&6>Edit Mode..."

View File

@@ -0,0 +1,111 @@
apartments_at:
debug: false
type: procedure
definitions: location
script:
- determine <[location].regions.filter_tag[<[filter_value].id.starts_with[apt-]>].get[1].if_null[null]>
apartments_owner:
debug: false
type: procedure
definitions: apartment
script:
- determine <[apartment].owners.get[1].if_null[null]>
apartments_access:
debug: false
type: procedure
definitions: player|location
script:
- define apartment <proc[apartments_at].context[<[location]>]>
- if <[apartment]> == null:
- determine true
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <[owner]> == null:
- determine false
- if <[owner]> == <[player]>:
- determine true
- define access <[owner].flag[apartments_access].get[<[apartment]>].get[<[player]>].if_null[null]>
- if <[access]> == null:
- determine false
- determine true
apartments_access_level:
debug: false
type: procedure
definitions: player|location
script:
- define apartment <proc[apartments_at].context[<[location]>]>
- if <[apartment]> == null:
- determine null
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <[owner]> == null:
- determine none
- if <[owner]> == <[player]>:
- determine owner
- define access <[owner].flag[apartments_access].get[<[apartment]>].get[<[player]>].if_null[null]>
- if <[access]> == null:
- determine none
- determine <[access]>
apartments_add_member:
debug: false
type: task
definitions: apartment|member
script:
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <[owner]> == null:
- stop
- define access_all <[owner].flag[apartments_access].get[<[apartment]>].if_null[<map[]>].with[<[member]>].as[member]>
- flag <[owner]> apartments_access:<[owner].flag[apartments_access].if_null[<map[]>].with[<[apartment]>].as[<[access_all]>]>
- execute as_server "as addfriend <[member].name> <[apartment].id>"
apartments_add_moderator:
debug: false
type: task
definitions: apartment|moderator
script:
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <[owner]> == null:
- stop
- execute as_server "rg addmember <[apartment].id> <[moderator].name> -w <[apartment].world.name>"
- define access_all <[owner].flag[apartments_access].get[<[apartment]>].if_null[<map[]>].with[<[moderator]>].as[moderator]>
- flag <[owner]> apartments_access:<[owner].flag[apartments_access].if_null[<map[]>].with[<[apartment]>].as[<[access_all]>]>
- execute as_server "as addfriend <[moderator].name> <[apartment].id>"
apartments_remove_access:
debug: false
type: task
definitions: apartment|member
script:
- define owner <proc[apartments_owner].context[<[apartment]>]>
- if <[owner]> == null:
- stop
- execute as_server "rg removemember <[apartment].id> <[member].name> -w <[apartment].world.name>"
- define access_all <[owner].flag[apartments_access].get[<[apartment]>].if_null[<map[]>].exclude[<[member]>]>
- flag <[owner]> apartments_access:<[owner].flag[apartments_access].if_null[<map[]>].with[<[apartment]>].as[<[access_all]>]>
- execute as_server "as delfriend <[member].name> <[apartment].id>"
apartments_begin_edit:
debug: false
type: task
definitions: apartment|player
script:
- definemap apartments_edit_data:
apartment: <[apartment]>
inventory: <[player].inventory.map_slots>
- flag <[player]> apartments_edit:<[apartments_edit_data]>
- inventory clear player:<[player]>
- adjust <[player]> gamemode:creative
apartments_end_edit:
debug: false
type: task
definitions: player
script:
- define apartments_edit_data <[player].flag[apartments_edit]>
- inventory clear player:<[player]>
- foreach <[apartments_edit_data].get[inventory]> key:slot as:item:
- inventory set origin:<[item]> slot:<[slot]> player:<[player]>
- adjust <[player]> gamemode:survival
- flag <[player]> apartments_edit:!

View File

@@ -0,0 +1,156 @@
apartments_world:
debug: false
type: world
events:
## session safety
on player joins:
- if <player.has_flag[apartments_edit]>:
- run apartments_end_edit def.player:<player>
## extra details
on delta time secondly every:2:
- actionbar "<&6>Editing apartment <&7>[<player.flag[apartments_edit].get[apartment].id>]" targets:<server.players_flagged[apartments_edit]> per_player
## invalid access
on player right clicks block:
- if <player.is_op>:
- stop
- if <context.location.if_null[null]> == null:
- stop
- if !<proc[apartments_access].context[<player>|<context.location>]>:
- determine cancelled
##
## complex creative safety cases
##
# do not allow leaving actual apartment region
on player walks:
- if !<player.has_flag[apartments_edit]>:
- stop
- define apartment <player.flag[apartments_edit].get[apartment]>
- if !<context.new_location.in_region[<[apartment].id>]>:
- determine cancelled
# forbid trying to touch non-blocks in creative inventory
on player clicks item in inventory:
- if !<player.has_flag[apartments_edit]>:
- stop
- if <context.click> != CREATIVE:
- determine cancelled
- if <player.open_inventory.inventory_type.if_null[CRAFTING]> != CRAFTING:
- determine cancelled
- if <context.item.material.is_block> && <context.cursor_item.material.is_block>:
- stop
- determine cancelled passively
- wait 1t
- inventory update destination:<player.inventory>
- adjust <player> item_on_cursor:<item[air]>
# handle container drops & illegal block breaks
on player breaks block bukkit_priority:monitor:
- if <player.is_op>:
- stop
# // careful: == null here; everywhere else it's != null
- if <proc[apartments_at].context[<context.location>]> == null:
- stop
- if <context.location.has_inventory>:
- if <player.gamemode> == creative:
- if <context.location.inventory.map_slots.size> > 0:
- narrate "<&c>This container has items inside. You must clear it first before you can break it."
- determine cancelled
- ratelimit <player> 1t
- define contents <context.location.inventory.map_slots.values>
- if <[contents].is_empty>:
- stop
- define half <context.location.material.half.if_null[null]>
- if <[half]> == right:
- define contents <[contents].get[1].to[27]>
- else if <[half]> == left:
- define contents <[contents].get[28].to[54]>
- foreach <[contents]> as:item:
- drop <[item]> <context.location> delay:10t
# forbid block update and physics inside apartments
on block physics:
- if <context.location.material.half.if_null[null]> != null:
- stop
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled passively
- foreach <context.location.find_entities[dropped_item].within[1]> as:entity:
- remove <[entity]>
# forbid block update and physics for half blocks
on player breaks block:
# // careful: == null here; everywhere else it's != null
- if <proc[apartments_at].context[<context.location>]> == null:
- stop
- define half <context.location.material.half.if_null[null]>
- if <[half]> != null && !<context.location.material.advanced_matches[*trapdoor|*stairs]>:
- if <context.new_material.name.if_null[air]> == air:
- if <[half]> != left && <[half]> != right:
- modifyblock <context.location.add[<context.location.material.relative_vector>]> air no_physics
# forbid blocks that have NBT data - such as prefilled chests
on player places block:
# // careful: == null here; everywhere else it's != null
- if <proc[apartments_at].context[<context.location>]> == null:
- stop
- if <player.is_op>:
- stop
- if <context.item_in_hand.material.advanced_matches[*banner]>:
- stop
- if <context.item_in_hand.all_raw_nbt.exclude[display].exclude[SkullOwner].filter_tag[<[filter_value].size.is_more_than[0]>].size.if_null[0]> > 0:
- determine cancelled
##
## simple creative safety cases
##
# forbid picking up and dropping items
on player drops item:
- if <player.is_op>:
- stop
- if <player.has_flag[apartments_edit]>:
- determine cancelled
on player picks up item:
- if <player.is_op>:
- stop
- if <player.has_flag[apartments_edit]>:
- determine cancelled
# forbid water flow in apartment regions
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
# forbid sapling/other growing things in apartment regions
on structure grows:
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
on plant grows:
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
# forbid any items dropping even if broken in apartment regions
on block drops item from breaking:
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
# forbid any tnt in apartment regions
on tnt primes:
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
# forbid gravity on blocks inside apartments
on block falls:
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
# forbid shulker box usage inside apartments
on player places *shulker_box:
- if <proc[apartments_at].context[<context.location>]> != null:
- if !<player.is_op>:
- determine cancelled
# forbid mob spawner usage inside apartments
on player places *spawner:
- if <player.is_op>:
- stop
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled
# prevent lectern grab
on player takes item from lectern:
- if <player.is_op>:
- stop
- if !<proc[apartments_access].context[<player>|<context.location>]>:
- determine cancelled
# prevent redstone in apartments
after redstone recalculated:
- if <proc[apartments_at].context[<context.location>]> != null:
- adjustblock <context.location> power:0 no_physics
# prevent piston use in apartments
on piston extends:
- if <proc[apartments_at].context[<context.location>]> != null:
- determine cancelled