Skip to content

Commit bf6c4c3

Browse files
committed
Replace all tabs with 4 spaces
1 parent 8c02127 commit bf6c4c3

File tree

6 files changed

+463
-463
lines changed

6 files changed

+463
-463
lines changed

Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ panic = 'abort' # Abort on panic. Supposedly helps reduzing binary size.
44

55
[workspace]
66
members = [
7-
"battlefield_rcon",
8-
"battlefox",
9-
"battlefox_discord",
10-
"battlelog",
11-
"battlefox_shared",
12-
"battlefox_database",
7+
"battlefield_rcon",
8+
"battlefox",
9+
"battlefox_discord",
10+
"battlelog",
11+
"battlefox_shared",
12+
"battlefox_database",
1313
]

battlefox/src/ban_enforcer.rs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,77 +13,77 @@ use crate::players::Players;
1313

1414
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
1515
pub struct Config {
16-
enabled: bool,
16+
enabled: bool,
1717
}
1818

1919
pub struct BanEnforcer {
20-
config: Config,
21-
db: BfoxDb,
20+
config: Config,
21+
db: BfoxDb,
2222
}
2323

2424
impl BanEnforcer {
25-
pub fn new(config: Config, _players: Arc<Players>, db: BfoxDb) -> Self {
26-
Self { config, db }
27-
}
25+
pub fn new(config: Config, _players: Arc<Players>, db: BfoxDb) -> Self {
26+
Self { config, db }
27+
}
2828

29-
async fn event(self: Arc<Self>, bf4: Arc<Bf4Client>, event: Event) -> RconResult<()> {
30-
#[allow(clippy::single_match)]
31-
match event {
32-
Event::Authenticated { player } => {
33-
match self.db.get_ban(format!("{}", player.eaid)).await {
34-
Ok(Some(ban)) => {
35-
let banned = if ban.status == BanStatus::Active {
36-
let now = OffsetDateTime::now_utc();
37-
let is_banned_time = now < ban.end;
29+
async fn event(self: Arc<Self>, bf4: Arc<Bf4Client>, event: Event) -> RconResult<()> {
30+
#[allow(clippy::single_match)]
31+
match event {
32+
Event::Authenticated { player } => {
33+
match self.db.get_ban(format!("{}", player.eaid)).await {
34+
Ok(Some(ban)) => {
35+
let banned = if ban.status == BanStatus::Active {
36+
let now = OffsetDateTime::now_utc();
37+
let is_banned_time = now < ban.end;
3838

39-
if !is_banned_time {
40-
warn!("Ban for player {player} is \"Active\" but endTime is in the past. All times (assumed) in UTC. Now = {}, ban_end = {}", &now, &ban.end);
41-
}
42-
is_banned_time
43-
} else {
44-
false
45-
};
39+
if !is_banned_time {
40+
warn!("Ban for player {player} is \"Active\" but endTime is in the past. All times (assumed) in UTC. Now = {}, ban_end = {}", &now, &ban.end);
41+
}
42+
is_banned_time
43+
} else {
44+
false
45+
};
4646

47-
if banned {
48-
info!("Player {player} is banned, and will be kicked via tempban for one second: {ban:#?}");
47+
if banned {
48+
info!("Player {player} is banned, and will be kicked via tempban for one second: {ban:#?}");
4949

50-
match bf4.ban_add(
51-
Ban::Guid(player.eaid),
52-
BanTimeout::Time(Duration::from_secs(1)), // I guess rcon will remove this by itself?
53-
Some(ban.reason.clone()) // reason
54-
).await {
55-
Ok(()) => (),
56-
Err(BanListError::BanListFull) => warn!("Ban list is full?!"),
57-
Err(BanListError::NotFound) => unreachable!(),
58-
Err(BanListError::Rcon(rcon_err)) => error!("Failed to tempban player for a second: {rcon_err:?}"),
59-
}
50+
match bf4.ban_add(
51+
Ban::Guid(player.eaid),
52+
BanTimeout::Time(Duration::from_secs(1)), // I guess rcon will remove this by itself?
53+
Some(ban.reason.clone()) // reason
54+
).await {
55+
Ok(()) => (),
56+
Err(BanListError::BanListFull) => warn!("Ban list is full?!"),
57+
Err(BanListError::NotFound) => unreachable!(),
58+
Err(BanListError::Rcon(rcon_err)) => error!("Failed to tempban player for a second: {rcon_err:?}"),
59+
}
6060

61-
match bf4.kick(player.name, ban.reason).await {
62-
Ok(()) => (),
63-
Err(PlayerKickError::PlayerNotFound) => (),
64-
Err(PlayerKickError::Rcon(rcon_err)) => error!("Failed to kick player: {rcon_err:?}"),
65-
}
66-
} else {
67-
debug!("Player {player} is in adkats_bans, but the ban has expired.");
68-
}
69-
},
70-
Ok(None) => (), // player is not banned
71-
Err(e) => error!("While checking player {player} for ban, got db error, but will ignore it and continue: {e}"),
72-
}
73-
},
74-
_ => (),
75-
}
61+
match bf4.kick(player.name, ban.reason).await {
62+
Ok(()) => (),
63+
Err(PlayerKickError::PlayerNotFound) => (),
64+
Err(PlayerKickError::Rcon(rcon_err)) => error!("Failed to kick player: {rcon_err:?}"),
65+
}
66+
} else {
67+
debug!("Player {player} is in adkats_bans, but the ban has expired.");
68+
}
69+
},
70+
Ok(None) => (), // player is not banned
71+
Err(e) => error!("While checking player {player} for ban, got db error, but will ignore it and continue: {e}"),
72+
}
73+
},
74+
_ => (),
75+
}
7676

77-
Ok(())
78-
}
77+
Ok(())
78+
}
7979
}
8080

8181
#[async_trait]
8282
impl Plugin for BanEnforcer {
8383
const NAME: &'static str = "ban_enforcer";
84-
fn enabled(&self) -> bool { self.config.enabled }
84+
fn enabled(&self) -> bool { self.config.enabled }
8585

8686
async fn event(self: Arc<Self>, bf4: Arc<Bf4Client>, event: Event) -> RconResult<()> {
87-
self.event(bf4, event).await
88-
}
87+
self.event(bf4, event).await
88+
}
8989
}

battlefox/src/commands.rs

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,23 @@ use combine::{Parser, EasyParser, many1, sep_by, token};
1414
use combine::parser::char::{letter, space};
1515

1616
pub trait Command {
17-
type Parameter;
17+
type Parameter;
1818

19-
fn target(arg: Self::Parameter);
19+
fn target(arg: Self::Parameter);
2020
}
2121

2222
pub trait ParserCommand : Command {
23-
fn parser<Input: Stream>() -> Box<dyn Parser<Input, Output = Self::Parameter, PartialState = ()>>;
23+
fn parser<Input: Stream>() -> Box<dyn Parser<Input, Output = Self::Parameter, PartialState = ()>>;
2424
}
2525

2626
pub struct CmdLifetime {
27-
handle: usize,
28-
commands: Arc<Commands>,
27+
handle: usize,
28+
commands: Arc<Commands>,
2929
}
3030

3131
impl Drop for CmdLifetime {
3232
fn drop(&mut self) {
33-
self.commands.cancel(self.handle);
33+
self.commands.cancel(self.handle);
3434
}
3535
}
3636

@@ -39,58 +39,58 @@ struct Inner {
3939
}
4040

4141
impl Inner {
42-
fn rebuild() {
43-
debug!("Rebuilding commands parser")
44-
}
42+
fn rebuild() {
43+
debug!("Rebuilding commands parser")
44+
}
4545
}
4646

4747
pub enum Matcher {
48-
/// For example `ban` will match `!ban PocketWolfy`, `/ban` etc.
49-
Exact(String),
50-
51-
/// For example `pearl`
52-
ExactOrPrefix {
53-
prefix: String,
54-
minlen: usize,
55-
}
48+
/// For example `ban` will match `!ban PocketWolfy`, `/ban` etc.
49+
Exact(String),
50+
51+
/// For example `pearl`
52+
ExactOrPrefix {
53+
prefix: String,
54+
minlen: usize,
55+
}
5656
}
5757

5858
pub struct Commands {
59-
inner: Mutex<Inner>,
59+
inner: Mutex<Inner>,
6060
}
6161

6262
impl Commands {
63-
pub fn new() -> Self {
64-
Self {
65-
inner: Mutex::new(Inner {
66-
}),
67-
}
68-
}
69-
70-
pub async fn run(&self, bf4: Arc<Bf4Client>) -> RconResult<()> {
63+
pub fn new() -> Self {
64+
Self {
65+
inner: Mutex::new(Inner {
66+
}),
67+
}
68+
}
69+
70+
pub async fn run(&self, bf4: Arc<Bf4Client>) -> RconResult<()> {
7171
let mut events = bf4.event_stream().await?;
7272
while let Some(event) = events.next().await {
7373
match event {
7474
Ok(Chat { vis, player, msg }) => {
7575

76-
},
77-
_ => (),
76+
},
77+
_ => (),
7878
}
79-
}
79+
}
8080

81-
Ok(())
82-
}
81+
Ok(())
82+
}
8383

84-
pub fn add_stage() {
84+
pub fn add_stage() {
8585

86-
}
86+
}
8787

88-
pub fn add_command() {
88+
pub fn add_command() {
8989

90-
}
90+
}
9191

92-
fn cancel(&self, handle: usize) {
92+
fn cancel(&self, handle: usize) {
9393

94-
}
94+
}
9595
}
9696

0 commit comments

Comments
 (0)