Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
ExtraJuiceMan committed Mar 21, 2018
1 parent af38801 commit 61dcd89
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 28 deletions.
4 changes: 2 additions & 2 deletions CommandIncrement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class CommandIncrement : IRocketCommand

public string Syntax => "";

public List<string> Aliases => new List<string> { };
public List<string> Aliases => new List<string>();

public List<string> Permissions => new List<string>() { "killstreaks.increment" };
public List<string> Permissions => new List<string> { "killstreaks.increment" };

public void Execute(IRocketPlayer caller, string[] args)
{
Expand Down
2 changes: 1 addition & 1 deletion CommandKills.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CommandKills : IRocketCommand

public List<string> Aliases => new List<string> { "killstreak" };

public List<string> Permissions => new List<string>() { "killstreaks.kills" };
public List<string> Permissions => new List<string> { "killstreaks.kills" };

public void Execute(IRocketPlayer caller, string[] args)
{
Expand Down
4 changes: 2 additions & 2 deletions CommandRemoveKS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public class CommandRemoveKS : IRocketCommand

public string Syntax => "";

public List<string> Aliases => new List<string> { };
public List<string> Aliases => new List<string>();

public List<string> Permissions => new List<string>() { "killstreaks.remove" };
public List<string> Permissions => new List<string> { "killstreaks.remove" };

public void Execute(IRocketPlayer caller, string[] args)
{
Expand Down
29 changes: 11 additions & 18 deletions KillStreaks.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using Rocket.Core.Plugins;
using System.Linq;
using Rocket.API.Collections;
using Rocket.Core;
using Rocket.Core.Logging;
using Rocket.Unturned.Player;
using Rocket.Core.Plugins;
using Rocket.Unturned;
using Rocket.Unturned.Chat;
using Rocket.Unturned.Events;
using Rocket.Unturned.Player;
using Steamworks;
using System.Collections.Generic;
using Rocket.Unturned.Chat;
using Rocket.Unturned;
using System.Xml.Serialization;
using System.IO;
using System.Linq;
using System.Xml;
using Rocket.API.Collections;
using Rocket.Core;
using System.Xml.Serialization;

namespace ExtraConcentratedJuice.KillStreaks
{
Expand Down Expand Up @@ -62,7 +62,6 @@ protected override void Load()
UnturnedPlayerEvents.OnPlayerDeath += OnDeath;
U.Events.OnPlayerDisconnected += OnDisconnected;
U.Events.OnPlayerConnected += OnConnected;

}

protected override void Unload()
Expand Down Expand Up @@ -140,7 +139,6 @@ private void OnDisconnected(UnturnedPlayer player)
if (killCount.TryGetValue(player.Id, out int count) && Configuration.Instance.remove_streak_on_disconnect)
{
killCount.Remove(player.Id);

}
}

Expand Down Expand Up @@ -185,7 +183,7 @@ private void OnDeath(UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.
{
if (killCount[killerPlayer.Id] >= group.KillMin && (killCount[killerPlayer.Id] <= group.KillMax || group.KillMax <= 0))
{
foreach(string cmd in group.Commands)
foreach (string cmd in group.Commands)
{
R.Commands.Execute(new Rocket.API.ConsolePlayer(), string.Format(cmd, killerPlayer.DisplayName));
}
Expand All @@ -194,17 +192,12 @@ private void OnDeath(UnturnedPlayer player, SDG.Unturned.EDeathCause cause, SDG.
}
}

public override TranslationList DefaultTranslations
{
get
{
return new TranslationList()
public override TranslationList DefaultTranslations =>
new TranslationList
{
{"killstreak_increment", "[KillStreaks] Your killstreak has been incremented."},
{"killstreak_count", "[KillStreaks] You are on a {0} killstreak."},
{"killstreak_remove", "[KillStreaks] Your killstreak has been reset."},
};
}
}
}
}
8 changes: 5 additions & 3 deletions KillStreaksConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class KillStreaksConfig : IRocketPluginConfiguration
public int kill_streak_lost_threshold;
public string kill_streak_lose_message;
public string kill_streak_lost_message_color;

[XmlArrayItem(ElementName = "Group")]
public List<CommandGroup> CommandGroups;

Expand All @@ -29,9 +30,9 @@ public void LoadDefaults()
kill_streak_lost_threshold = 25;
kill_streak_lose_message = "{0} DIED AND LOST THEIR KILL STREAK OF {1}!";
kill_streak_lost_message_color = "red";
CommandGroups = new List<CommandGroup>()
CommandGroups = new List<CommandGroup>
{
new CommandGroup { Commands = new List<string>() { "/heal {0}", "/give {0} 8 1", "/say woah" }, KillMin = 4, KillMax = 20 }
new CommandGroup { Commands = new List<string> { "/heal {0}", "/give {0} 8 1", "/say woah" }, KillMin = 4, KillMax = 20 }
};
}

Expand All @@ -43,8 +44,9 @@ public CommandGroup()

[XmlArrayItem(ElementName = "Command")]
public List<string> Commands;

public int KillMin;
public int KillMax;
}
}
}
}
3 changes: 1 addition & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
Expand Down Expand Up @@ -33,4 +32,4 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit 61dcd89

Please sign in to comment.