Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Commit

Permalink
Merge branch '1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlOfDuty committed Jan 14, 2019
2 parents a6fc37d + 2abc6a5 commit 4584120
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 37 deletions.
9 changes: 6 additions & 3 deletions SCPDiscordPlugin/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public static class Config
// Round events
{ "channels.onroundstart", new string[]{ } },
{ "channels.onconnect", new string[]{ } },
{ "channels.ondisconnect", new string[]{ } },
{ "channels.ondisconnect.default", new string[]{ } },
{ "channels.ondisconnect.banned", new string[]{ } },
{ "channels.oncheckroundend", new string[]{ } },
{ "channels.onroundend", new string[]{ } },
{ "channels.onwaitingforplayers", new string[]{ } },
Expand Down Expand Up @@ -111,8 +112,10 @@ public static class Config
// Admin events
{ "channels.onadminquery", new string[]{ } },
{ "channels.onauthcheck", new string[]{ } },
{ "channels.onban.admin", new string[]{ } },
{ "channels.onban.console", new string[]{ } },
{ "channels.onban.admin.kick", new string[]{ } },
{ "channels.onban.console.kick", new string[]{ } },
{ "channels.onban.admin.ban", new string[]{ } },
{ "channels.onban.console.ban", new string[]{ } },
// Team events
{ "channels.ondecideteamrespawnqueue", new string[]{ } },
{ "channels.onsetrolemaxhp", new string[]{ } },
Expand Down
26 changes: 20 additions & 6 deletions SCPDiscordPlugin/EventListeners/AdminEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace SCPDiscord
{
//Comments here are my own as there were none in the Smod2 api
class AdminEventListener : IEventHandlerAdminQuery, IEventHandlerAuthCheck, IEventHandlerBan
internal class AdminEventListener : IEventHandlerAdminQuery, IEventHandlerAuthCheck, IEventHandlerBan
{
private readonly SCPDiscord plugin;

Expand All @@ -17,7 +17,7 @@ public AdminEventListener(SCPDiscord plugin)
public void OnAdminQuery(AdminQueryEvent ev)
{
///Triggered whenever an adming uses an admin command, both gui and commandline RA
if(ev.Query == "REQUEST_DATA PLAYER_LIST SILENT")
if (ev.Query == "REQUEST_DATA PLAYER_LIST SILENT")
{
return;
}
Expand Down Expand Up @@ -58,7 +58,7 @@ public void OnAuthCheck(AuthCheckEvent ev)

public void OnBan(BanEvent ev)
{
if(ev.Admin != null)
if (ev.Admin != null)
{
Dictionary<string, string> variables = new Dictionary<string, string>
{
Expand All @@ -79,7 +79,14 @@ public void OnBan(BanEvent ev)
{ "adminclass", ev.Admin.TeamRole.Role.ToString() },
{ "adminteam", ev.Admin.TeamRole.Team.ToString() }
};
plugin.SendMessage(Config.GetArray("channels.onban.admin"), "admin.onban.admin", variables);
if (ev.Duration == 0)
{
plugin.SendMessage(Config.GetArray("channels.onban.admin.kick"), "admin.onban.admin.kick", variables);
}
else
{
plugin.SendMessage(Config.GetArray("channels.onban.admin.ban"), "admin.onban.admin.ban", variables);
}
}
else
{
Expand All @@ -96,8 +103,15 @@ public void OnBan(BanEvent ev)
{ "playerclass", ev.Player.TeamRole.Role.ToString() },
{ "playerteam", ev.Player.TeamRole.Team.ToString() }
};
plugin.SendMessage(Config.GetArray("channels.onban.console"), "admin.onban.console", variables);
if (ev.Duration == 0)
{
plugin.SendMessage(Config.GetArray("channels.onban.console.kick"), "admin.onban.console.kick", variables);
}
else
{
plugin.SendMessage(Config.GetArray("channels.onban.console.ban"), "admin.onban.console.ban", variables);
}
}
}
}
}
}
37 changes: 22 additions & 15 deletions SCPDiscordPlugin/EventListeners/RoundEventListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

namespace SCPDiscord
{
class RoundEventListener : IEventHandlerRoundStart, IEventHandlerRoundEnd, IEventHandlerConnect, IEventHandlerDisconnect, IEventHandlerWaitingForPlayers,
internal class RoundEventListener : IEventHandlerRoundStart, IEventHandlerRoundEnd, IEventHandlerConnect, IEventHandlerDisconnect, IEventHandlerWaitingForPlayers,
IEventHandlerCheckRoundEnd, IEventHandlerRoundRestart, IEventHandlerSetServerName, IEventHandlerSceneChanged
{
private readonly SCPDiscord plugin;
bool roundHasStarted = false;
private bool roundHasStarted = false;

public RoundEventListener(SCPDiscord plugin)
{
Expand All @@ -20,7 +20,7 @@ public void OnRoundStart(RoundStartEvent ev)
{
/// <summary>
/// This is the event handler for Round start events (before people are spawned in)
/// </summary>
/// </summary>
plugin.SendMessage(Config.GetArray("channels.onroundstart"), "round.onroundstart");
roundHasStarted = true;
}
Expand All @@ -46,25 +46,32 @@ public void OnDisconnect(DisconnectEvent ev)
{
{ "ipaddress", ev.Connection.IpAddress }
};
plugin.SendMessage(Config.GetArray("channels.ondisconnect"), "round.ondisconnect", variables);
if (ev.Connection.IsBanned)
{
plugin.SendMessage(Config.GetArray("channels.ondisconnect.banned"), "round.ondisconnect.banned", variables);
}
else
{
plugin.SendMessage(Config.GetArray("channels.ondisconnect.default"), "round.ondisconnect.default", variables);
}
}

public void OnCheckRoundEnd(CheckRoundEndEvent ev)
{
/// <summary>
/// <summary>
/// This event handler will call everytime the game checks for a round end
/// </summary>
/// </summary>

//Protip, don't turn this on.
plugin.SendMessage(Config.GetArray("channels.oncheckroundend"), "round.oncheckroundend");
}

public void OnRoundEnd(RoundEndEvent ev)
{
/// <summary>
/// <summary>
/// This is the event handler for Round end events (when the stats appear on screen)
/// </summary>
if(roundHasStarted && ev.Round.Duration > 60)
if (roundHasStarted && ev.Round.Duration > 60)
{
Dictionary<string, string> variables = new Dictionary<string, string>
{
Expand Down Expand Up @@ -92,26 +99,26 @@ public void OnRoundEnd(RoundEndEvent ev)

public void OnWaitingForPlayers(WaitingForPlayersEvent ev)
{
/// <summary>
/// <summary>
/// This event handler will call when the server is waiting for players
/// </summary>
/// </summary>
plugin.SendMessage(Config.GetArray("channels.onwaitingforplayers"), "round.onwaitingforplayers");
}

public void OnRoundRestart(RoundRestartEvent ev)
{
/// <summary>
/// <summary>
/// This event handler will call when the server is about to restart
/// </summary>
/// </summary>
plugin.SendMessage(Config.GetArray("channels.onroundrestart"), "round.onroundrestart");
}

public void OnSetServerName(SetServerNameEvent ev)
{
/// <summary>
/// <summary>
/// This event handler will call when the server name is set
/// </summary>
ev.ServerName = (ConfigManager.Manager.Config.GetBoolValue("discord_metrics", true)) ? ev.ServerName += "<color=#ffffff00><size=1>SCPD:" + plugin.Details.version + "</size></color>" : ev.ServerName;
ev.ServerName = (ConfigManager.Manager.Config.GetBoolValue("discord_metrics", true)) ? ev.ServerName += "<color=#ffffff00><size=1>SCPD:" + plugin.Details.version + "</size></color>" : ev.ServerName;

Dictionary<string, string> variables = new Dictionary<string, string>
{
Expand All @@ -129,4 +136,4 @@ public void OnSceneChanged(SceneChangedEvent ev)
plugin.SendMessage(Config.GetArray("channels.onscenechanged"), "round.onscenechanged", variables);
}
}
}
}
9 changes: 6 additions & 3 deletions SCPDiscordPlugin/Language.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ internal static class Language
{
"round.onroundstart",
"round.onconnect",
"round.ondisconnect",
"round.ondisconnect.default",
"round.ondisconnect.banned",
"round.oncheckroundend",
"round.onroundend",
"round.onwaitingforplayers",
Expand Down Expand Up @@ -103,8 +104,10 @@ internal static class Language

"admin.onadminquery",
"admin.onauthcheck",
"admin.onban.admin",
"admin.onban.console",
"admin.onban.admin.kick",
"admin.onban.console.kick",
"admin.onban.admin.ban",
"admin.onban.console.ban",

"team.ondecideteamrespawnqueue",
"team.onteamrespawn.mtf",
Expand Down
28 changes: 21 additions & 7 deletions SCPDiscordPlugin/Languages/english.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,14 @@ round:
message: "Player attempting connection..."
regex: []
ondisconnect:
# ipaddress - string
message: "A player has disconnected."
regex: []
default:
# ipaddress - string
message: "A player has disconnected."
regex: []
banned:
# ipaddress - string
message: "A player has disconnected because they are banned."
regex: []
oncheckroundend:
message: "Checking if round has ended..."
regex: []
Expand Down Expand Up @@ -209,6 +214,7 @@ environment:
mtf:
message: "**MTF helicopter is in visual range of the site, preparing to land.**"
regex: []

player:
onplayerhurt:
# damage - float
Expand Down Expand Up @@ -705,11 +711,19 @@ admin:
# adminclass - Role
# adminteam - Team
admin:
message: "Player <var:playername> (<var:playersteamid>) was banned by <var:adminname> (<var:adminsteamid>) for <var:duration> minutes. Reason: <var:reason>"
regex: []
ban:
message: "Player <var:playername> (<var:playersteamid>) was banned by <var:adminname> (<var:adminsteamid>) for <var:duration> minutes. Reason: <var:reason>"
regex: []
kick:
message: "Player <var:playername> (<var:playersteamid>) was kicked by <var:adminname> (<var:adminsteamid>). Reason: <var:reason>"
regex: []
console:
message: "<var:playername> (<var:playersteamid>) was banned by Skynet for <var:duration> minutes. Reason: <var:reason>"
regex: []
ban:
message: "Player <var:playername> (<var:playersteamid>) was banned by Skynet for <var:duration> minutes. Reason: <var:reason>"
regex: []
kick:
message: "Player <var:playername> (<var:playersteamid>) was kicked by Skynet. Reason: <var:reason>"
regex: []

team:
ondecideteamrespawnqueue:
Expand Down
13 changes: 10 additions & 3 deletions SCPDiscordPlugin/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ channels:
# Round events
onroundstart: [ "default", "staff" ]
onconnect: [ "default", "staff" ]
ondisconnect: [ "default", "staff" ]
ondisconnect:
default: [ "default", "staff" ]
banned: [ "default", "staff" ]
oncheckroundend: []
onroundend: [ "default", "staff" ]
onwaitingforplayers: [ "default" ]
Expand Down Expand Up @@ -124,8 +126,13 @@ channels:
onadminquery: [ "staff" ]
onauthcheck: [ "staff" ]
onban:
admin: [ "default", "staff" ]
console: [ "default", "staff" ]
admin:
kick: [ "default", "staff" ]
ban: [ "default", "staff" ]
console:
kick: [ "default", "staff" ]
ban: [ "default", "staff" ]


# Team events
ondecideteamrespawnqueue: []
Expand Down

0 comments on commit 4584120

Please sign in to comment.