Skip to content

Commit

Permalink
Bug fixes, new event
Browse files Browse the repository at this point in the history
  • Loading branch information
stwxdev committed Apr 27, 2021
1 parent 9dc9582 commit 9fa7ec6
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 6 deletions.
4 changes: 3 additions & 1 deletion BetterBroadcast/BetterBroadcast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class BetterBroadcast : Qurre.Plugin
{
public override string Name => "BetterBroadcast";
public override string Developer => "stwx.";
public override Version Version => new Version(1, 0, 0);
public override Version Version => new Version(1, 0, 1);
public override Version NeededQurreVersion => new Version(1, 2, 12);
private EventHandlers EventHandlers;
public override void Enable()
Expand All @@ -17,6 +17,7 @@ public override void Enable()
Round.Start += EventHandlers.RoundStart;
Round.Restart += EventHandlers.RoundRestart;
Round.End += EventHandlers.RoundEnd;
Player.Dies += EventHandlers.Dies;
}
public override void Reload() => Enable();
public override void Disable()
Expand All @@ -25,6 +26,7 @@ public override void Disable()
Round.Start -= EventHandlers.RoundStart;
Round.Restart -= EventHandlers.RoundRestart;
Round.End -= EventHandlers.RoundEnd;
Player.Dies -= EventHandlers.Dies;
EventHandlers = null;
}
}
Expand Down
6 changes: 4 additions & 2 deletions BetterBroadcast/BetterBroadcast.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
<Reference Include="0Harmony">
<HintPath>..\references_qurre\0Harmony.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp">
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\references_qurre\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp-firstpass">
Expand All @@ -46,7 +47,8 @@
<Reference Include="Newtonsoft.Json">
<HintPath>..\references_qurre\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Qurre">
<Reference Include="Qurre, Version=1.2.12.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\references_qurre\Qurre.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand Down
10 changes: 9 additions & 1 deletion BetterBroadcast/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
{
public static class Config
{
//Plugin Settings
public static bool EnablePlugin = Qurre.Plugin.Config.GetBool("bb_enable", true);

//Player Join Message
public static bool EnablePlayerJoinMessage = Qurre.Plugin.Config.GetBool("bb_ply_join_msg_on", true);
public static string PlayerJoinMessageText = Qurre.Plugin.Config.GetString("bb_ply_join_text", "<color=yellow>Welcome to my server!</color>");
public static string PlayerJoinMessageText = Qurre.Plugin.Config.GetString("bb_ply_join_text", "<color=yellow>Welcome to my server <color=red>%player%</color>!</color>");
public static int PlayerJoinMessageDuration = Qurre.Plugin.Config.GetInt("bb_ply_join_msg_dur", 10);

//Start Round Message
Expand All @@ -22,5 +25,10 @@ public static class Config
public static string RoundMessageText = Qurre.Plugin.Config.GetString("bb_round_text", "<color=green>DISCORD: discord.gg/</color>");
public static int RoundMessageDuration = Qurre.Plugin.Config.GetInt("bb_round_dur", 10);
public static float RoundMessageInterval = Qurre.Plugin.Config.GetFloat("bb_round_msg_interval", 100);

//Player Die Message
public static bool EnablePlayerDieMessage = Qurre.Plugin.Config.GetBool("bb_player_die_msg_on", true);
public static string PlayerDieText = Qurre.Plugin.Config.GetString("bb_player_die_text", "You were killed by player <color=red>%killer%</color>");
public static int PlayerDieMessageDuration = Qurre.Plugin.Config.GetInt("bb_player_die_msg_dur", 4);
}
}
42 changes: 40 additions & 2 deletions BetterBroadcast/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ namespace BetterBroadcast
{
public class EventHandlers
{
bool BroadcastNow;
public void RoundEnd(RoundEndEvent ev)
{
Timing.KillCoroutines("MessageLoop");
Expand All @@ -15,6 +16,12 @@ public void RoundEnd(RoundEndEvent ev)
if (Config.EndRoundMessageText != string.Empty && Config.EndRoundMessageDuration > 0)
{
Map.Broadcast(Config.EndRoundMessageText, (ushort)Config.EndRoundMessageDuration, true);
BroadcastNow = true;
float delay = Config.EndRoundMessageDuration;
Timing.CallDelayed(delay, delegate ()
{
BroadcastNow = false;
});
}
}
}
Expand All @@ -29,6 +36,12 @@ public void RoundStart()
if (Config.StartRoundMessageText != string.Empty && Config.StartRoundMessageDuration > 0)
{
Map.Broadcast(Config.StartRoundMessageText, (ushort)Config.StartRoundMessageDuration, true);
BroadcastNow = true;
float delay = Config.StartRoundMessageDuration;
Timing.CallDelayed(delay, delegate ()
{
BroadcastNow = false;
});
}
}
if (Config.EnableRoundMessage)
Expand All @@ -45,16 +58,41 @@ public void PlayerJoin(JoinEvent ev)
{
if (Config.PlayerJoinMessageText != string.Empty && Config.PlayerJoinMessageDuration > 0)
{
ev.Player.Broadcast((ushort)Config.PlayerJoinMessageDuration, Config.PlayerJoinMessageText, true);
string message = Config.PlayerJoinMessageText.Replace("%player%", $"{ev.Player.Nickname}");
ev.Player.Broadcast((ushort)Config.PlayerJoinMessageDuration, message, true);
}
}
}

public void Dies(DiesEvent ev)
{
if (Config.EnablePlayerDieMessage)
{
if (Config.PlayerDieText != string.Empty && Config.PlayerDieMessageDuration > 0)
{
ev.Allowed = true;
if (ev.Killer != ev.Target)
{
string message = Config.PlayerDieText.Replace("%killer%", $"{ev.Killer.Nickname}");
ev.Target.Broadcast((ushort)Config.PlayerDieMessageDuration, message, true);
}
else
{
ev.Target.Broadcast((ushort)Config.PlayerDieMessageDuration, "<color=red>$UICIDE BOY</color>", true);
}
}
}
}

IEnumerator<float>RoundMessage()
{
for(;;)
{
yield return Timing.WaitForSeconds(Config.RoundMessageInterval);
Map.Broadcast(Config.RoundMessageText, (ushort)Config.RoundMessageDuration, true);
if (!BroadcastNow)
{
Map.Broadcast(Config.RoundMessageText, (ushort)Config.RoundMessageDuration, true);
}
}
}
}
Expand Down
Binary file modified BetterBroadcast/bin/Debug/Assembly-CSharp.dll
Binary file not shown.
Binary file modified BetterBroadcast/bin/Debug/BetterBroadcast.dll
Binary file not shown.
Binary file modified BetterBroadcast/bin/Debug/BetterBroadcast.pdb
Binary file not shown.
Binary file modified BetterBroadcast/bin/Debug/Qurre.dll
Binary file not shown.
Binary file not shown.
Binary file added BetterBroadcast/obj/Debug/BetterBroadcast.dll
Binary file not shown.
Binary file added BetterBroadcast/obj/Debug/BetterBroadcast.pdb
Binary file not shown.

0 comments on commit 9fa7ec6

Please sign in to comment.