--antigrief things made by mewmew --rewritten by gerkiz-- --as an admin, write either /trust or /untrust and the players name in the chat to grant/revoke immunity from protection local Event = require 'utils.event' local Session = require 'utils.datastore.session_data' local Global = require 'utils.global' local Utils = require 'utils.core' local Color = require 'utils.color_presets' local Server = require 'utils.server' local Jail = require 'utils.datastore.jail_data' local FancyTime = require 'utils.tools.fancy_time' local Task = require 'utils.task' local Token = require 'utils.token' local Discord = require 'utils.discord_handler' local Public = {} local match = string.match local de = defines.events local sub = string.sub local format = string.format local floor = math.floor local random = math.random local abs = math.abs local this = { enabled = true, max_count_decon = 1500, landfill_history = {}, capsule_history = {}, friendly_fire_history = {}, mining_history = {}, whitelist_mining_history = {}, corpse_history = {}, message_history = {}, cancel_crafting_history = {}, deconstruct_history = {}, scenario_history = {}, whitelist_types = {}, permission_group_editing = {}, players_warned = {}, damage_history = {}, punish_cancel_craft = false, do_not_check_trusted = false, enable_autokick = false, enable_autoban = false, enable_jail = true, enable_capsule_warning = true, enable_capsule_cursor_warning = true, required_playtime = 2592000, capsule_bomb_threshold = 8, damage_entity_threshold = 20, enable_jail_when_decon = true, enable_jail_on_long_texts = true, filtered_types_on_decon = {}, decon_surface_blacklist = 'nauvis', players_warn_when_decon = {}, players_warn_on_long_texts = {}, on_cancelled_deconstruction = {tick = 0, count = 0}, limit = 2000, admin_button_validation = {} } local blacklisted_types = { ['transport-belt'] = true, ['wall'] = true, ['underground-belt'] = true, ['inserter'] = true, ['land-mine'] = true, ['gate'] = true, ['lamp'] = true, ['mining-drill'] = true, ['splitter'] = true } local ammo_names = { ['artillery-targeting-remote'] = true, ['poison-capsule'] = true, ['cluster-grenade'] = true, ['grenade'] = true, ['atomic-bomb'] = true, ['cliff-explosives'] = true, ['rocket'] = true } local chests = { ['container'] = true, ['logistic-container'] = true } -- Clears the player from players_warn_when_decon tbl. local clear_player_decon_warnings = Token.register( function(event) local player_index = event.player_index if this.players_warn_when_decon[player_index] then this.players_warn_when_decon[player_index] = nil end end ) -- Clears the player from players_warn_on_long_texts tbl. local clear_players_warn_on_long_texts = Token.register( function(event) local player_index = event.player_index if this.players_warn_on_long_texts[player_index] then this.players_warn_on_long_texts[player_index] = nil end end ) Global.register( this, function(t) this = t end ) local function increment(t, v) t[#t + 1] = (v or 1) end -- Removes the first 100 entries of a table local function overflow(t) for _ = 1, 100, 1 do table.remove(t, 1) end end local function get_entities(item_name, entities) local set = {} for i = 1, #entities do local e = entities[i] local name = e.name if name ~= item_name and name ~= 'entity-ghost' then local count = set[name] if count then set[name] = count + 1 else set[name] = 1 end end end local list = {} local i = 1 for k, v in pairs(set) do list[i] = v i = i + 1 list[i] = ' ' i = i + 1 list[i] = k i = i + 1 list[i] = ', ' i = i + 1 end list[i - 1] = nil return table.concat(list) end local function damage_player(player, kill, print_to_all) local msg = ' tried to destroy our base, but it backfired!' if player.character then if kill then player.character.die('enemy') if print_to_all then game.print(player.name .. msg, Color.yellow) end return end player.character.health = player.character.health - random(50, 100) player.character.surface.create_entity({name = 'water-splash', position = player.position}) local messages = { 'Ouch.. That hurt! Better be careful now.', 'Just a fleshwound.', 'Better keep those hands to yourself or you might loose them.' } player.print(messages[random(1, #messages)], Color.yellow) if player.character.health <= 0 then player.character.die('enemy') game.print(player.name .. msg, Color.yellow) return end end end local function do_action(player, prefix, msg, ban_msg, kill) if not prefix or not msg or not ban_msg then return end kill = kill or false damage_player(player, kill) Utils.action_warning(prefix, msg) if this.players_warned[player.index] == 2 then if this.enable_autoban then Server.ban_sync(player.name, ban_msg, '