Files
furniture-protection.sk
README.txt
Code
2 224
furniture-protection.sk
# FurnitureProtection Skript
# Prevents non-OP players from breaking ItemsAdder furniture in WorldGuard regions
# Compatible with Minecraft 1.17.1
#
# Required Addons:
# - Skellett (for file operations and WorldGuard integration)
# - SkBee or SkQuery (for ItemsAdder detection)
#
# Installation:
# 1. Place this file in plugins/Skript/scripts/
# 2. Ensure you have Skellett addon installed
# 3. Run /sk reload furniture-protection
# 4. Logs will be saved to plugins/Skript/logs/furniture-attempts.log
options:
prefix: &6[&eFurnitureProtect&6]&r
deny-message: &cYou cannot break furniture in this area!
permission-message: &cYou don't have permission to break furniture here.
region-name: __global__
log-file: plugins/Skript/logs/furniture-attempts.log
enable-console-alerts: true
on script load:
send "{@prefix} &aFurniture Protection loaded successfully!" to console
send "{@prefix} &7Protected region: &e{@region-name}" to console
send "{@prefix} &7Log file: &e{@log-file}" to console
if file "{@log-file}" doesn't exist:
create file "{@log-file}"
write "=== Furniture Protection Log ===%nl%Started: %now%%nl%%nl%" to file "{@log-file}"
send "{@prefix} &7Created new log file" to console
on break:
if player is op:
stop
set {_item} to event-block
set {_location} to location of event-block
set {_world} to world of event-block
if name of {_item} contains "furniture" or "iasurvival:" or "itemsadder:":
set {_isFurniture} to true
else if lore of {_item} contains "ItemsAdder" or "Furniture":
set {_isFurniture} to true
else if tag "custom;ItemsAdder" of nbt of {_item} is set:
set {_isFurniture} to true
else:
set {_isFurniture} to false
if {_isFurniture} is true:
set {_regions::*} to regions at {_location}
if {_regions::*} contains "{@region-name}":
cancel event
send "{@prefix} {@deny-message}" to player
set {_timestamp} to now
set {_playerName} to name of player
set {_x} to x-coordinate of {_location}
set {_y} to y-coordinate of {_location}
set {_z} to z-coordinate of {_location}
set {_blockType} to type of event-block
set {_logEntry} to "[%{_timestamp}%] Player: %{_playerName}% | Location: %{_world}% (%{_x}%, %{_y}%, %{_z}%) | Block: %{_blockType}% | Region: {@region-name}%nl%"
write {_logEntry} to file "{@log-file}"
if {@enable-console-alerts} is true:
send "{@prefix} &e%{_playerName}%&7 attempted to break furniture at &e%{_x}%, %{_y}%, %{_z}%&7 in region &e{@region-name}" to console
loop all players:
if loop-player has permission "furniture.admin":
send "{@prefix} &e%{_playerName}%&7 tried to break furniture at &e%{_x}%, %{_y}%, %{_z}%" to loop-player
command /furnitureprotect [<text>] [<text>]:
aliases: /fp, /furnprotect
permission: furniture.admin
permission message: {@permission-message}
trigger:
if arg-1 is not set:
send "{@prefix} &7Furniture Protection Commands:"
send "&e/fp reload &7- Reload the script"
send "&e/fp log [lines] &7- View recent log entries"
send "&e/fp clear &7- Clear the log file"
send "&e/fp info &7- View protection info"
stop
if arg-1 is "reload":
make console execute command "/sk reload furniture-protection"
send "{@prefix} &aScript reloaded!" to player
stop
if arg-1 is "log":
if file "{@log-file}" doesn't exist:
send "{@prefix} &cLog file not found!" to player
stop
set {_lines} to 10
if arg-2 is set:
set {_lines} to arg-2 parsed as integer
if {_lines} is not set:
set {_lines} to 10
send "{@prefix} &7Showing last &e%{_lines}%&7 log entries:" to player
send "&7&m------------------------" to player
set {_content} to file contents of "{@log-file}"
set {_logLines::*} to {_content} split at nl
set {_total} to size of {_logLines::*}
set {_start} to {_total} - {_lines}
if {_start} < 1:
set {_start} to 1
loop {_logLines::*}:
if loop-index >= {_start}:
send "&7%loop-value%" to player
send "&7&m------------------------" to player
stop
if arg-1 is "clear":
delete file "{@log-file}"
wait 2 ticks
create file "{@log-file}"
write "=== Furniture Protection Log ===%nl%Cleared: %now%%nl%%nl%" to file "{@log-file}"
send "{@prefix} &aLog file cleared successfully!" to player
stop
if arg-1 is "info":
send "{@prefix} &7Protection Information:" to player
send "&7Protected Region: &e{@region-name}" to player
send "&7Log File: &e{@log-file}" to player
send "&7Console Alerts: &e{@enable-console-alerts}" to player
send "&7OPs Bypassed: &aYes" to player
stop
send "{@prefix} &cUnknown command. Use &e/fp&c for help." to player
function logFurnitureAttempt(p: player, loc: location, blockName: text):
set {_timestamp} to now
set {_playerName} to name of {_p}
set {_x} to x-coordinate of {_loc}
set {_y} to y-coordinate of {_loc}
set {_z} to z-coordinate of {_loc}
set {_world} to world of {_loc}
set {_logEntry} to "[%{_timestamp}%] Player: %{_playerName}% | Location: %{_world}% (%{_x}%, %{_y}%, %{_z}%) | Block: %{_blockName}% | Region: {@region-name}%nl%"
write {_logEntry} to file "{@log-file}"