Skip to content

Commit

Permalink
Merge pull request #435 from ComfyFactory/changes
Browse files Browse the repository at this point in the history
Changes
  • Loading branch information
Gerkiz authored Nov 12, 2023
2 parents 5fd9eec + 84821cb commit 7e38c6c
Show file tree
Hide file tree
Showing 7 changed files with 281 additions and 59 deletions.
6 changes: 3 additions & 3 deletions maps/mountain_fortress_v3/gui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,10 @@ local function create_main_frame(player)
player.gui.top['wave_defense'].visible = true
end

local frame = player.gui.top.add({type = 'frame', name = main_frame_name})
local frame = player.gui.top.add({type = 'frame', name = main_frame_name, style = 'finished_game_subheader_frame'})
frame.location = {x = 1, y = 40}
frame.style.minimal_height = 37
frame.style.maximal_height = 37
frame.style.minimal_height = 38
frame.style.maximal_height = 38

label = frame.add({type = 'label', caption = ' ', name = 'label'})
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
Expand Down
5 changes: 2 additions & 3 deletions modules/wave_defense/gui.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
local Public = require 'modules.wave_defense.table'
local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local Gui = require 'utils.gui'

local floor = math.floor

local function create_gui(player)
local frame = player.gui.top.add({type = 'frame', name = 'wave_defense', style = Gui.frame_style})
frame.style.maximal_height = 37
local frame = player.gui.top.add({type = 'frame', name = 'wave_defense', style = 'finished_game_subheader_frame'})
frame.style.maximal_height = 38

local label = frame.add({type = 'label', caption = ' ', name = 'label'})
label.style.font_color = {r = 0.88, g = 0.88, b = 0.88}
Expand Down
18 changes: 17 additions & 1 deletion utils/antigrief.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ local this = {
players_warn_when_decon = {},
players_warn_on_long_texts = {},
on_cancelled_deconstruction = {tick = 0, count = 0},
limit = 2000
limit = 2000,
admin_button_validation = {}
}

local blacklisted_types = {
Expand Down Expand Up @@ -1199,6 +1200,21 @@ function Public.get(key)
end
end

--- Change or add a value
---@param key any
---@param value any
---@return boolean|string|integer|table
function Public.set(key, value)
if key and (value or value == false) then
this[key] = value
return this[key]
elseif key then
return this[key]
else
return this
end
end

Event.on_init(on_init)
Event.add(de.on_player_mined_entity, on_player_mined_entity)
Event.add(de.on_entity_died, on_entity_died)
Expand Down
42 changes: 33 additions & 9 deletions utils/datastore/jail_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ local function create_gulag_surface()
return surface
end

local function teleport_player_to_gulag(player, action)
local function teleport_player_to_gulag(player, action, mute)
local p_data = get_player_data(player)
if not p_data then
return
Expand All @@ -332,6 +332,7 @@ local function teleport_player_to_gulag(player, action)
p_data.position = player.position
p_data.p_group_id = player.permission_group.group_id
p_data.locked = true
p_data.muted = mute or false
end
player.teleport(gulag.find_non_colliding_position('character', {0, 0}, 128, 1), gulag.name)
local data = {
Expand Down Expand Up @@ -436,12 +437,12 @@ local function validate_args(data)
end

if player.name == offender then
Utils.print_to(player, module_name .. 'You can´t jail yourself.')
Utils.print_to(player, module_name .. 'You can´t select yourself.')
return false
end

if get_offender_player.admin and not player.admin then
Utils.print_to(player, module_name .. 'You can´t jail an admin.')
Utils.print_to(player, module_name .. 'You can´t select an admin.')
return false
end

Expand Down Expand Up @@ -606,13 +607,13 @@ local function jail(player, offender, msg, raised, mute)
return
end

draw_notice_frame(to_jail_player)

if to_jail_player.character and to_jail_player.character.valid and to_jail_player.character.driving then
to_jail_player.character.driving = false
end

teleport_player_to_gulag(to_jail_player, 'jail')
teleport_player_to_gulag(to_jail_player, 'jail', mute)

draw_notice_frame(to_jail_player)

if mute then
local gulag = get_super_gulag_permission_group()
Expand Down Expand Up @@ -666,7 +667,7 @@ local function jail_temporary(player, offender, msg, mute)
offender.character.driving = false
end

teleport_player_to_gulag(offender, 'jail')
teleport_player_to_gulag(offender, 'jail', mute)

if mute then
local gulag = get_super_gulag_permission_group()
Expand Down Expand Up @@ -897,6 +898,11 @@ draw_notice_frame = function(player)

local warning_message = '[font=heading-2]You have been jailed.[/font]\nPlease respond to questions if you are asked something.'

local p_data = get_player_data(player)
if p_data and p_data.muted then
warning_message = '[font=heading-2]You have been jailed and muted.[/font]\nPlease seek out assistance at our discord: https://getcomfy.eu/discord.'
end

label_flow.style.horizontally_stretchable = false
local label = label_flow.add {type = 'label', caption = warning_message}
label.style.single_line = false
Expand Down Expand Up @@ -1050,6 +1056,24 @@ function Public.normies_can_jail(value)
settings.normies_can_jail = value or false
end

---
--- Mutes a player completely from chatting
---@param player LuaPlayer
function Public.mute_player(player)
if not player or not player.valid then
return error('Player was not valid.')
end

local gulag = get_super_gulag_permission_group()
if not gulag.players[player.index] then
gulag.add_player(player)
return true
else
gulag.remove_player(player)
return false
end
end

Server.on_data_set_changed(
jailed_data_set,
function(data)
Expand Down Expand Up @@ -1350,7 +1374,7 @@ Event.add(
if player.surface.index ~= surface.index then
local p_data = get_player_data(player)
if jailed[player.name] and p_data and p_data.locked then
teleport_player_to_gulag(player, 'jail')
teleport_player_to_gulag(player, 'jail', p_data.muted or false)
end
end

Expand Down Expand Up @@ -1379,7 +1403,7 @@ Event.add(
if player.surface.index ~= surface.index then
local p_data = get_player_data(player)
if jailed[player.name] and p_data and p_data.locked then
teleport_player_to_gulag(player, 'jail')
teleport_player_to_gulag(player, 'jail', p_data.muted or false)
draw_notice_frame(player)
end
end
Expand Down
25 changes: 7 additions & 18 deletions utils/datastore/session_data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,8 @@ local get_total_playtime_token =
local nth_tick_token =
Token.register(
function(data)
local index = data.index
local player = game.get_player(index)
if player and player.valid then
Public.try_ul_data(player.name)
end
local player_name = data.name
Public.try_ul_data(player_name)
end
)

Expand All @@ -173,7 +170,7 @@ local function upload_data()
for i = 1, #players do
count = count + 10
local player = players[i]
set_timeout_in_ticks(count, nth_tick_token, {index = player.index})
set_timeout_in_ticks(count, nth_tick_token, {name = player.name})
end
end

Expand Down Expand Up @@ -329,15 +326,9 @@ function Public.clear_player(player)
local connected = player.connected

if not connected then
if session[name] then
session[name] = nil
end
if online_track[name] then
online_track[name] = nil
end
if trusted[name] then
trusted[name] = nil
end
session[name] = nil
online_track[name] = nil
trusted[name] = nil
end
end
end
Expand All @@ -346,9 +337,7 @@ end
---@param player LuaPlayer
function Public.reset_online_track(player)
local name = player.name
if online_track[name] then
online_track[name] = 0
end
online_track[name] = 0
end

--- It's vital that we reset the online_track so we
Expand Down
Loading

0 comments on commit 7e38c6c

Please sign in to comment.