Skip to content
This repository has been archived by the owner on Sep 12, 2020. It is now read-only.

Commit

Permalink
Merge pull request #14 from SynapseSL/development
Browse files Browse the repository at this point in the history
Version 1.1.2
  • Loading branch information
moelrobi authored Aug 4, 2020
2 parents 3f1ba8b + 184f178 commit 24ac13e
Show file tree
Hide file tree
Showing 31 changed files with 230 additions and 258 deletions.
2 changes: 1 addition & 1 deletion Synapse/Api/Decontamination.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Synapse.Api
{
public static class Decontamination
{
public static DecontaminationController Controller { get => DecontaminationController.Singleton; }
public static DecontaminationController Controller => DecontaminationController.Singleton;

public static bool IsDecontaminationDisabled
{
Expand Down
7 changes: 2 additions & 5 deletions Synapse/Api/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using CommandSystem;
using Harmony;
using Mirror;
using Synapse.Api.Enums;
using Synapse.Api.Plugin;
using UnityEngine;
Expand Down Expand Up @@ -85,7 +82,7 @@ public static Player GetPlayer(this ICommandSender sender)
/// <summary>
/// Gives you the player object
/// </summary>
public static Player GetPlayer(this MonoBehaviour mono) => mono.GetComponent<Player>();
public static Player GetPlayer(this MonoBehaviour mono) => mono.gameObject.GetPlayer();

/// <summary>
/// Gives you the player object
Expand Down
7 changes: 2 additions & 5 deletions Synapse/Api/Jail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ public class Jail : MonoBehaviour
/// <summary>
/// The Player which is Jailed
/// </summary>
public Player Player
{
get => this.GetPlayer();
}

public Player Player => this.GetPlayer();

/// <summary>
/// The Admins which Jailed the Player
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Synapse/Api/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static class Map
/// <summary>
/// Gives you a list of all rooms
/// </summary>
public static List<Room> Rooms
public static IEnumerable<Room> Rooms
{
get
{
Expand Down Expand Up @@ -179,7 +179,7 @@ public static Pickup SpawnItem(ItemType itemType, float durability, Vector3 posi
{
var p = Server.Host.Inventory.SetPickup(itemType, -4.656647E+11f, position,Quaternion.identity, 0, 0, 0);

GameObject gameObject = p.gameObject;
var gameObject = p.gameObject;
gameObject.transform.localScale = scale;

NetworkServer.UnSpawn(gameObject);
Expand Down
20 changes: 10 additions & 10 deletions Synapse/Api/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static IEnumerable<Player> GetAllPlayers()
/// <summary>
/// Gives you the player object
/// </summary>
public static Player GetPlayer(int id) => Player.GetAllPlayers().FirstOrDefault(p => p.PlayerId == id);
public static Player GetPlayer(int id) => GetAllPlayers().FirstOrDefault(p => p.PlayerId == id);

/// <summary>
/// Gives you the player object
Expand All @@ -42,12 +42,12 @@ public static Player GetPlayer(string arg)

if (!arg.EndsWith("@steam") && !arg.EndsWith("@discord") && !arg.EndsWith("@northwood") &&
!arg.EndsWith("@patreon"))
return Player.GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower()));
foreach (var player in Player.GetAllPlayers())
return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower()));
foreach (var player in GetAllPlayers())
if (player.UserId == arg)
return player;

return Player.GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower()));
return GetAllPlayers().FirstOrDefault(p => p.NickName.ToLower().Contains(arg.ToLower()));
}


Expand Down Expand Up @@ -93,7 +93,7 @@ public CommandSender CommandSender
get
{
if (this == Host) return ServerConsole._scs;
else return QueryProcessor._sender;
return QueryProcessor._sender;
}
}

Expand Down Expand Up @@ -323,7 +323,7 @@ public Player Cuffer
/// <summary>
/// The UserGroup the player is in
/// </summary>
public UserGroup Rank { get => ServerRoles.Group; set => ServerRoles.SetGroup(value, value != null ? value.Permissions > 0UL : false,true); }
public UserGroup Rank { get => ServerRoles.Group; set => ServerRoles.SetGroup(value, value != null && value.Permissions > 0UL,true); }

/// <summary>
/// The name of the group the user has
Expand Down Expand Up @@ -565,18 +565,18 @@ public void Hurt(int amount, DamageTypes.DamageType damagetype = default,Player
/// <param name="port">The Port of the Server the Player should be send to</param>
public void SendToServer(ushort port)
{
PlayerStats component = Host.PlayerStats;
NetworkWriter writer = NetworkWriterPool.GetWriter();
var component = Host.PlayerStats;
var writer = NetworkWriterPool.GetWriter();
writer.WriteSingle(1f);
writer.WriteUInt16(port);
RpcMessage msg = new RpcMessage
var msg = new RpcMessage
{
netId = component.netId,
componentIndex = component.ComponentIndex,
functionHash = Server.GetMethodHash(typeof(PlayerStats), "RpcRoundrestartRedirect"),
payload = writer.ToArraySegment()
};
Connection.Send<RpcMessage>(msg, 0);
Connection.Send(msg);
NetworkWriterPool.Recycle(writer);
}
}
Expand Down
12 changes: 6 additions & 6 deletions Synapse/Api/Plugin/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Synapse.Api.Plugin
{
public abstract class Plugin
{
internal Assembly assembly;
internal Assembly Assembly;
/// <summary>
/// The Main Config from the current Server which all Plugins can use
/// </summary>
Expand Down Expand Up @@ -49,7 +49,7 @@ public string OwnPluginFolder

public virtual void RegisterCommands()
{
foreach(var type in assembly.GetTypes())
foreach(var type in Assembly.GetTypes())
{
if (type.GetInterface("ICommand") != typeof(ICommand)) continue;

Expand All @@ -61,17 +61,17 @@ public virtual void RegisterCommands()
{
if (attributeData.AttributeType != typeof(CommandHandlerAttribute)) continue;

var cmdtype = (Type)attributeData.ConstructorArguments?[0].Value;
var cmdType = (Type)attributeData.ConstructorArguments[0].Value;

var cmd = (ICommand)Activator.CreateInstance(type);

if (cmdtype == typeof(RemoteAdminCommandHandler))
if (cmdType == typeof(RemoteAdminCommandHandler))
Server.RaCommandHandler.RegisterCommand(cmd);

if (cmdtype == typeof(GameConsoleCommandHandler))
if (cmdType == typeof(GameConsoleCommandHandler))
Server.GameCoreCommandHandler.RegisterCommand(cmd);

if (cmdtype == typeof(ClientCommandHandler))
if (cmdType == typeof(ClientCommandHandler))
Server.ClientCommandHandler.RegisterCommand(cmd);
}
catch (Exception e)
Expand Down
7 changes: 2 additions & 5 deletions Synapse/Api/Plugin/Translation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ public void CreateTranslations(Dictionary<string,string> translations)
var newlines = new List<string>();
var position = 0;

foreach (var rawpair in translations.ToList())
foreach (var pair in translations.ToList().Select(rawPair => new KeyValuePair<string,string>(rawPair.Key,rawPair.Value.Replace("\n", "\\n"))))
{
var pair = new KeyValuePair<string,string>(rawpair.Key,rawpair.Value.Replace("\n", "\\n"));

if (lines.Length > position)
{
if (string.IsNullOrEmpty(lines[position]))
Expand Down Expand Up @@ -57,8 +55,7 @@ public string GetTranslation(string translationName)
try
{
var trans = _translation.FirstOrDefault(x => x.Key == translationName).Value;
if (trans == null) return "Plugin requested a not created Translation!";
return trans.Replace("\\n", "\n");
return trans == null ? "Plugin requested a not created Translation!" : trans.Replace("\\n", "\n");
}
catch
{
Expand Down
12 changes: 6 additions & 6 deletions Synapse/Api/Round.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ public static class Round
/// </summary>
public static bool IsLocked{ get => RoundSummary.RoundLock; set => RoundSummary.RoundLock = value; }

public static int Escaped_Ds { get => RoundSummary.escaped_ds; set => RoundSummary.escaped_ds = value; }
public static int EscapedDs { get => RoundSummary.escaped_ds; set => RoundSummary.escaped_ds = value; }

public static int Escaped_Scientists { get => RoundSummary.escaped_scientists; set => RoundSummary.escaped_scientists = value; }
public static int EscapedScientists { get => RoundSummary.escaped_scientists; set => RoundSummary.escaped_scientists = value; }

public static int Kills_by_Scps { get => RoundSummary.kills_by_scp; set => RoundSummary.kills_by_scp = value; }
public static int KillsByScps { get => RoundSummary.kills_by_scp; set => RoundSummary.kills_by_scp = value; }

public static int Changed_into_Zombies { get => RoundSummary.changed_into_zombies; set => RoundSummary.changed_into_zombies = value; }
public static int ChangedIntoZombies { get => RoundSummary.changed_into_zombies; set => RoundSummary.changed_into_zombies = value; }

/// <summary>
/// Activates/Deactivates the LobbyLock (if the Lobby can continue counting down)
/// </summary>
public static bool IsLobbyLocked{ get => GameCore.RoundStart.LobbyLock; set => GameCore.RoundStart.LobbyLock = value; }
public static bool IsLobbyLocked{ get => RoundStart.LobbyLock; set => RoundStart.LobbyLock = value; }

public static void Restart() => Player.Host.PlayerStats.Roundrestart();

public static void Start() => CharacterClassManager.ForceRoundStart();

public static void MTFRespawn(bool isCI = false)
public static void MtfRespawn(bool isCI = false)
{
var component = Server.Host.GetComponent<RespawnManager>();
component.NextKnownTeam = isCI ? SpawnableTeamType.ChaosInsurgency : SpawnableTeamType.NineTailedFox;
Expand Down
16 changes: 8 additions & 8 deletions Synapse/Api/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ namespace Synapse.Api
public static class Server
{
private static MethodInfo _sendSpawnMessage;
private static Broadcast broadcast;
private static BanPlayer banPlayer;
private static Broadcast _broadcast;
private static BanPlayer _banPlayer;


public static Player Host => Player.Host;
Expand Down Expand Up @@ -43,21 +43,21 @@ public static Broadcast Broadcast
{
get
{
if (broadcast == null)
broadcast = Host.GetComponent<Broadcast>();
if (_broadcast == null)
_broadcast = Host.GetComponent<Broadcast>();

return broadcast;
return _broadcast;
}
}

public static BanPlayer BanPlayer
{
get
{
if (banPlayer == null)
banPlayer = Host.GetComponent<BanPlayer>();
if (_banPlayer == null)
_banPlayer = Host.GetComponent<BanPlayer>();

return banPlayer;
return _banPlayer;
}
}

Expand Down
20 changes: 10 additions & 10 deletions Synapse/Api/Warhead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,32 @@
{
public static class Warhead
{
private static AlphaWarheadController controller;
private static AlphaWarheadNukesitePanel nukesitePanel;
private static AlphaWarheadController _controller;
private static AlphaWarheadNukesitePanel _nukeSitePanel;

public static AlphaWarheadController Controller
{
get
{
if (controller == null)
controller = Player.Host.GetComponent<AlphaWarheadController>();
if (_controller == null)
_controller = Player.Host.GetComponent<AlphaWarheadController>();

return controller;
return _controller;
}
}

public static AlphaWarheadNukesitePanel NukesitePanel
public static AlphaWarheadNukesitePanel NukeSitePanel
{
get
{
if (nukesitePanel == null)
nukesitePanel = Player.Host.GetComponent<AlphaWarheadNukesitePanel>();
if (_nukeSitePanel == null)
_nukeSitePanel = Player.Host.GetComponent<AlphaWarheadNukesitePanel>();

return nukesitePanel;
return _nukeSitePanel;
}
}

public static bool LeverStatus { get => NukesitePanel.Networkenabled; set => NukesitePanel.Networkenabled = value; }
public static bool LeverStatus { get => NukeSitePanel.Networkenabled; set => NukeSitePanel.Networkenabled = value; }

public static float DetonationTimer
{
Expand Down
15 changes: 7 additions & 8 deletions Synapse/Config/SynapseConfigs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,19 @@ internal static class SynapseConfigs
internal static string JoinBroadcast;
internal static string JoinTextHint;
internal static ushort JoinMessageDuration;
internal static List<int> Speaking_Scps;
internal static bool Nametracking;
internal static List<int> SpeakingScps;
internal static bool NameTracking;

// Methods
internal static void ReloadConfig()
{
RequiredForFemur = Plugin.Config.GetInt("synapse_femur",1);
RemoteKeyCard = Plugin.Config.GetBool("synapse_remote_keycard", false);
JoinBroadcast = Plugin.Config.GetString("synapse_join_broadcast", "");
JoinTextHint = Plugin.Config.GetString("synapse_join_texthint", "");
RemoteKeyCard = Plugin.Config.GetBool("synapse_remote_keycard");
JoinBroadcast = Plugin.Config.GetString("synapse_join_broadcast");
JoinTextHint = Plugin.Config.GetString("synapse_join_texthint");
JoinMessageDuration = Plugin.Config.GetUShort("synapse_join_duration",5);
Speaking_Scps = Plugin.Config.GetIntList("synapse_speakingscps");
if (Speaking_Scps == null) Speaking_Scps = new List<int> { 16, 17 };
Nametracking = Plugin.Config.GetBool("synapse_nametracking",true);
SpeakingScps = Plugin.Config.GetIntList("synapse_speakingscps") ?? new List<int> { 16, 17 };
NameTracking = Plugin.Config.GetBool("synapse_nametracking",true);
}
}
}
9 changes: 2 additions & 7 deletions Synapse/Events/EventHandlers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Synapse.Events.Classes;
using Synapse.Config;
using UnityEngine;
using System;

namespace Synapse.Events
{
Expand Down Expand Up @@ -33,13 +32,9 @@ private static void OnDoorInteract(DoorInteractEvent ev)
if (ev.Allow) return;

if (!ev.Player.Items.Any()) return;
foreach (var item in ev.Player.Items)
foreach (var gameItem in ev.Player.Items.Select(item => ev.Player.Inventory.GetItemByID(item.id)).Where(gameitem => gameitem.permissions != null && gameitem.permissions.Length != 0))
{
var gameitem = ev.Player.Inventory.GetItemByID(item.id);

if (gameitem.permissions == null || gameitem.permissions.Length == 0) continue;

ev.Allow = gameitem.permissions.Any(p =>
ev.Allow = gameItem.permissions.Any(p =>
Door.backwardsCompatPermissions.TryGetValue(p, out var flag) &&
ev.Door.PermissionLevels.HasPermission(flag));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public static bool Prefix(PlayerInteract __instance, GameObject doorId)

__instance.OnInteract();

if (__instance._sr.BypassMode) allowTheAccess = true;
if (__instance._sr.BypassMode) {}
else if (door.PermissionLevels.HasPermission(Door.AccessRequirements.Checkpoints) &&
__instance._ccm.CurRole.team == Team.SCP) allowTheAccess = true;
__instance._ccm.CurRole.team == Team.SCP) {}
else
{
try
Expand Down
Loading

0 comments on commit 24ac13e

Please sign in to comment.