public void SetVesselProtection(Guid guid, VesselProtectionType protection)
 {
     lock (vesselPermissions)
     {
         if (!vesselPermissions.ContainsKey(guid))
         {
             return;
         }
         vesselPermissions[guid].protection = protection;
         SaveVesselPermissions(guid);
     }
 }
Example #2
0
 public void SetVesselProtection(Guid guid, VesselProtectionType protection)
 {
     if (!PlayerIsVesselOwner(dmpSettings.playerName, guid))
     {
         return;
     }
     using (MessageWriter mw = new MessageWriter())
     {
         mw.Write <int>((int)PermissionMessageType.SET_PERMISSION_LEVEL);
         mw.Write <string>(guid.ToString());
         mw.Write <string>(protection.ToString());
         networkWorker.SendPermissionsMessage(mw.GetMessageBytes());
     }
 }
        public static void HandleMessage(ClientObject client, byte[] data)
        {
            using (MessageReader mr = new MessageReader(data))
            {
                int type = mr.Read <int>();
                switch ((PermissionMessageType)type)
                {
                case PermissionMessageType.PERMISSION_REQUEST:
                    Messages.PermissionMessage.SendVesselPermissionsToClient(client);
                    break;

                case PermissionMessageType.SET_OWNER:
                {
                    Guid   guid  = Guid.Parse(mr.Read <string>());
                    string owner = mr.Read <string>();
                    if (Permissions.fetch.PlayerIsVesselOwner(client.playerName, guid))
                    {
                        Permissions.fetch.SetVesselOwner(guid, owner);
                    }
                }
                break;

                case PermissionMessageType.SET_GROUP:
                {
                    Guid   guid  = Guid.Parse(mr.Read <string>());
                    string group = mr.Read <string>();
                    if (Permissions.fetch.PlayerIsVesselOwner(client.playerName, guid))
                    {
                        Permissions.fetch.SetVesselGroup(guid, group);
                    }
                }
                break;

                case PermissionMessageType.SET_PERMISSION_LEVEL:
                {
                    Guid   guid            = Guid.Parse(mr.Read <string>());
                    string permissionLevel = mr.Read <string>();
                    VesselProtectionType vesselProtection = (VesselProtectionType)Enum.Parse(typeof(VesselProtectionType), permissionLevel);
                    if (Permissions.fetch.PlayerIsVesselOwner(client.playerName, guid))
                    {
                        Permissions.fetch.SetVesselProtection(guid, vesselProtection);
                    }
                }
                break;
                }
            }
        }