--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 'tools.fancy_time' local Public = {} local match = string.match local capsule_bomb_threshold = 8 local de = defines.events local format = string.format local this = { enabled = true, landfill_history = {}, capsule_history = {}, friendly_fire_history = {}, mining_history = {}, whitelist_mining_history = {}, corpse_history = {}, message_history = {}, cancel_crafting_history = {}, whitelist_types = {}, permission_group_editing = {}, players_warned = {}, damage_history = {}, punish_cancel_craft = false, do_not_check_trusted = true, enable_autokick = false, enable_autoban = false, enable_jail = false, enable_capsule_warning = false, enable_capsule_cursor_warning = false, required_playtime = 2592000, damage_entity_threshold = 20, explosive_threshold = 16, limit = 2000 } 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 } Global.register( this, function(t) this = t end ) local function increment(t, v) t[#t + 1] = (v or 1) 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 - math.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[math.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, '